27 #include <tqptrlist.h>
28 #include "tdeglobal.h"
30 #include <tdeapplication.h>
31 #include <tdeaboutdata.h>
33 #include <tdeconfig.h>
35 #include <kcharsets.h>
36 #include <kiconloader.h>
37 #ifdef __TDE_HAVE_TDEHWLIB
38 #include <tdehardwaredevices.h>
39 #include <tdenetworkconnections.h>
41 #include <kstandarddirs.h>
42 #include <kinstance.h>
43 #include "kstaticdeleter.h"
48 #define MYASSERT(x) if (!x) \
49 tqFatal("Fatal error: you need to have a TDEInstance object before\n" \
50 "you do anything that requires it! Examples of this are config\n" \
51 "objects, standard directories or translations.");
56 static void kglobal_init();
62 return _instance->
dirs();
69 return _instance->
config();
86 #ifdef __TDE_HAVE_TDEHWLIB
87 TDEHardwareDevices *TDEGlobal::hardwareDevices()
91 return _instance->hardwareDevices();
94 TDEGlobalNetworkManager *TDEGlobal::networkManager()
98 return _instance->networkManager();
116 TDELocale::initInstance();
118 _instance->
aboutData()->translateInternalProgramName();
126 if( _charsets == 0 ) {
153 class KStringDict :
public TQDict<TQString>
156 KStringDict() : TQDict<TQString>(139) { }
169 _stringDict =
new KStringDict;
170 _stringDict->setAutoDelete(
true );
173 TQString *result = _stringDict->find(str);
176 result =
new TQString(str);
177 _stringDict->insert(str, result);
182 class KStaticDeleterList:
public TQPtrList<KStaticDeleterBase>
185 KStaticDeleterList() { }
191 if (!_staticDeleters)
193 if (_staticDeleters->find(obj) == -1)
194 _staticDeleters->append(obj);
201 _staticDeleters->removeRef(obj);
207 if (!TDEGlobal::_staticDeleters)
210 for(;_staticDeleters->count();)
212 _staticDeleters->take(0)->destructObject();
215 delete TDEGlobal::_staticDeleters;
216 TDEGlobal::_staticDeleters = 0;
221 KStringDict *TDEGlobal::_stringDict = 0;
226 KStaticDeleterList *TDEGlobal::_staticDeleters = 0;
230 static void kglobal_freeAll();
231 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID impLoad )
233 if (reason == DLL_PROCESS_DETACH)
238 __attribute__((destructor))
240 static void kglobal_freeAll()
242 delete TDEGlobal::_locale;
243 TDEGlobal::_locale = 0;
244 delete TDEGlobal::_charsets;
245 TDEGlobal::_charsets = 0;
246 delete TDEGlobal::_stringDict;
247 TDEGlobal::_stringDict = 0;
253 static void kglobal_init()
255 if (TDEGlobal::_staticDeleters)
258 TDEGlobal::_staticDeleters =
new KStaticDeleterList;
261 int kasciistricmp(
const char *str1,
const char *str2 )
263 const unsigned char *s1 = (
const unsigned char *)str1;
264 const unsigned char *s2 = (
const unsigned char *)str2;
266 unsigned char c1, c2;
269 return s1 ? 1 : (s2 ? -1 : 0);
271 return *s1 ? 1 : (*s2 ? -1 : 0);
272 for (;*s1; ++s1, ++s2) {
274 if (c1 >=
'A' && c1 <=
'Z')
276 if (c2 >=
'A' && c2 <=
'Z')
282 return *s1 ? res : (*s2 ? -1 : 0);
285 char* kasciitolower(
char *s )
289 for (
unsigned char *p = (
unsigned char *) s; *p; ++p )
290 *p = ( *p >=
'A' && *p <=
'Z' ) ? (*p -
'A' +
'a') : *p;
294 char* kasciitoupper(
char *s )
298 for (
unsigned char *p = (
unsigned char *) s; *p; ++p )
299 *p = ( *p >=
'a' && *p <=
'z' ) ? (*p -
'a' +
'A') : *p;
Charset font and encoder/decoder handling.
Static deleters are used to manage static resources.
Access KDE Configuration entries.
static TDEIconLoader * iconLoader()
Returns an iconloader object.
static TDEConfig * config()
Returns the general config object.
static void unregisterStaticDeleter(KStaticDeleterBase *d)
Unregisters a static deleter.
static TDEStandardDirs * dirs()
Returns the application standard dirs object.
static TDESharedConfig * sharedConfig()
Returns the general config object.
static KCharsets * charsets()
The global charset manager.
static TDEInstance * instance()
Returns the global instance.
static void registerStaticDeleter(KStaticDeleterBase *d)
Registers a static deleter.
static TDELocale * locale()
Returns the global locale object.
static void setActiveInstance(TDEInstance *d)
The instance currently active (useful in a multi-instance application, such as a KParts application).
static void deleteStaticDeleters()
Calls KStaticDeleterBase::destructObject() on all registered static deleters and unregisters them all...
static const TQString & staticQString(const char *str)
Creates a static TQString.
Access to KDE global objects for use in shared libraries.
TDEStandardDirs * dirs() const
Returns the application standard dirs object.
TQCString instanceName() const
Returns the name of the instance.
TDEConfig * config() const
Returns the general config object ("appnamerc").
const TDEAboutData * aboutData() const
Returns the about data of this instance Warning, can be 0L.
TDEIconLoader * iconLoader() const
Returns an iconloader object.
TDESharedConfig * sharedConfig() const
Returns the general config object ("appnamerc").
TDELocale provides support for country specific stuff like the national language.
void setActiveCatalogue(const TQString &catalog)
Sets the active catalog for translation lookup.
TDEConfig variant using shared memory.
Site-independent access to standard KDE directories.