18 #include "kinstance.h" 23 #include "tdeconfig.h" 25 #include "kcharsets.h" 26 #include "kiconloader.h" 27 #ifdef __TDE_HAVE_TDEHWLIB 28 #include "klibloader.h" 29 #include "tdeversion.h" 30 #include "tdehardwaredevices.h" 31 #include "tdenetworkconnections.h" 33 #include "tdeaboutdata.h" 34 #include "tdestandarddirs.h" 36 #include "tdeglobal.h" 37 #include "kmimesourcefactory.h" 44 #include <tqptrdict.h> 45 static TQPtrList<TDEInstance> *allInstances = 0;
46 static TQPtrDict<TQCString> *allOldInstances = 0;
47 #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); 48 #define DEBUG_REMOVE do { allInstances->removeRef(this); } while (false); 49 #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); 53 #define DEBUG_CHECK_ALIVE 56 class TDEInstancePrivate
61 mimeSourceFactory = 0L;
64 ~TDEInstancePrivate ()
66 delete mimeSourceFactory;
79 #ifdef __TDE_HAVE_TDEHWLIB
80 _hardwaredevices (0L),
83 _name( name ), _aboutData( new
TDEAboutData( name,
"", 0 ) ), m_configReadOnly(false)
86 Q_ASSERT(!name.isEmpty());
87 if (!TDEGlobal::_instance)
89 TDEGlobal::_instance =
this;
93 d =
new TDEInstancePrivate ();
94 d->ownAboutdata =
true;
101 #ifdef __TDE_HAVE_TDEHWLIB
102 _hardwaredevices (0L),
103 _networkmanager (0L),
105 _name( aboutData->appName() ), _aboutData( aboutData ), m_configReadOnly(false)
108 Q_ASSERT(!_name.isEmpty());
110 if (!TDEGlobal::_instance)
112 TDEGlobal::_instance =
this;
116 d =
new TDEInstancePrivate ();
117 d->ownAboutdata =
false;
121 : _dirs ( src->_dirs ),
122 _config ( src->_config ),
123 _iconLoader ( src->_iconLoader ),
124 #ifdef __TDE_HAVE_TDEHWLIB 125 _hardwaredevices ( src->_hardwaredevices ),
126 _networkmanager ( src->_networkmanager ),
128 _name( src->_name ), _aboutData( src->_aboutData ), m_configReadOnly(
false)
131 Q_ASSERT(!_name.isEmpty());
133 if (!TDEGlobal::_instance || TDEGlobal::_instance == src )
135 TDEGlobal::_instance =
this;
139 d =
new TDEInstancePrivate ();
140 d->ownAboutdata = src->d->ownAboutdata;
141 d->sharedConfig = src->d->sharedConfig;
145 src->_iconLoader = 0L;
146 #ifdef __TDE_HAVE_TDEHWLIB 147 src->_hardwaredevices = 0L;
148 src->_networkmanager = 0L;
150 src->_aboutData = 0L;
168 #ifdef __TDE_HAVE_TDEHWLIB 169 delete _hardwaredevices;
170 _hardwaredevices = 0;
172 delete _networkmanager;
181 if (TDEGlobal::_instance ==
this)
182 TDEGlobal::_instance = 0;
183 if (TDEGlobal::activeInstance() ==
this)
204 extern bool kde_kiosk_exception;
205 extern bool kde_kiosk_admin;
209 m_configReadOnly = ro;
216 if ( !d->configName.isEmpty() )
221 d->sharedConfig->setGroup(
"KDE Action Restrictions" );
222 TQString kioskException = d->sharedConfig->readEntry(
"kiosk_exception");
223 if (d->sharedConfig->readBoolEntry(
"custom_config",
true))
225 d->sharedConfig->setGroup(TQString::null);
234 if ( d->sharedConfig == 0 )
236 if ( !_name.isEmpty() ) {
245 if (kde_kiosk_admin && !kde_kiosk_exception && !TQCString(getenv(
"TDE_KIOSK_NO_RESTRICTIONS")).isEmpty())
247 kde_kiosk_exception =
true;
252 _config = d->sharedConfig;
267 return d->sharedConfig;
273 d->configName = configName;
279 if( _iconLoader == 0 ) {
287 #ifdef __TDE_HAVE_TDEHWLIB 288 TDEHardwareDevices *TDEInstance::hardwareDevices()
const 291 if (_hardwaredevices == 0)
293 TQString libName = TQString(
"libtdehw.so.%1").arg(TDE_VERSION_MAJOR);
297 TDEHardwareDevices* (*create)() = (TDEHardwareDevices* (*)())lib->
symbol(
"create_tdeHardwareDevices");
300 _hardwaredevices = create();
305 return _hardwaredevices;
308 TDEGlobalNetworkManager *TDEInstance::networkManager()
const 311 if (_networkmanager == 0)
313 TQString libName = TQString(
"libtdehw.so.%1").arg(TDE_VERSION_MAJOR);
317 TDEGlobalNetworkManager* (*create)() = (TDEGlobalNetworkManager* (*)())lib->
symbol(
"create_tdeGlobalNetworkManager");
320 _networkmanager = create();
325 return _networkmanager;
351 if (!d->mimeSourceFactory)
354 d->mimeSourceFactory->setInstance(const_cast<TDEInstance *>(
this));
357 return d->mimeSourceFactory;
360 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.
KMimeSourceFactory * mimeSourceFactory() const
Returns the KMimeSourceFactory of the instance.
This class is used to store information about a program.
TQCString instanceName() const
Returns the name of the instance.
TDEStandardDirs * dirs() const
Returns the application standard dirs object.
Site-independent access to standard TDE directories.
void reconfigure(const TQString &_appname, TDEStandardDirs *_dirs)
Called by TDEInstance::newIconLoader to reconfigure the icon loader.
void * symbol(const char *name) const
Looks up a symbol from the library.
Represents a dynamically loaded library.
static void reconfigure()
Reconfigure the theme.
virtual KLibrary * library(const char *libname)
Loads and initializes a library.
void setConfigReadOnly(bool ro)
Set a read-only flag on the configuration files This must be called before config() or dirs() to have...
static KLibLoader * self()
Returns a pointer to the factory.
bool addCustomized(TDEConfig *config)
Reads customized entries out of the given config object and add them via addResourceDirs().
TDEIconLoader * iconLoader() const
Returns an iconloader object.
TDEConfig variant using shared memory.
void setConfigName(const TQString &name)
Set name of default config file.
void newIconLoader() const
Re-allocate the global iconloader.
const TDEAboutData * aboutData() const
Returns the about data of this instance Warning, can be 0L.
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)...
TDEConfig * config() const
Returns the general config object ("appnamerc").
TDESharedConfig * sharedConfig() const
Returns the general config object ("appnamerc").
virtual ~TDEInstance()
Destructor.
TDEInstance(const TQCString &instanceName)
Constructor.