30#include <tdeapplication.h>
31#include <tdeaboutdata.h>
36#include <kiconloader.h>
37#ifdef __TDE_HAVE_TDEHWLIB
38#include <tdehardwaredevices.h>
39#include <tdenetworkconnections.h>
41#include <kstandarddirs.h>
42#include <tdeinstance.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.");
56static void kglobal_init();
62 return _instance->dirs();
69 return _instance->config();
76 return _instance->sharedConfig();
83 return _instance->iconLoader();
86#ifdef __TDE_HAVE_TDEHWLIB
87TDEHardwareDevices *TDEGlobal::hardwareDevices()
91 return _instance->hardwareDevices();
94TDEGlobalNetworkManager *TDEGlobal::networkManager()
98 return _instance->networkManager();
116 TDELocale::initInstance();
117 if( _instance->aboutData())
118 _instance->aboutData()->translateInternalProgramName();
126 if( _charsets == 0 ) {
138 _locale->setActiveCatalogue(TQString::fromUtf8(i->
instanceName()));
153class 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);
182class 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;
221KStringDict *TDEGlobal::_stringDict = 0;
226KStaticDeleterList *TDEGlobal::_staticDeleters = 0;
230static void kglobal_freeAll();
231BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID impLoad )
233 if (reason == DLL_PROCESS_DETACH)
238__attribute__((destructor))
240static 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;
253static void kglobal_init()
255 if (TDEGlobal::_staticDeleters)
258 TDEGlobal::_staticDeleters =
new KStaticDeleterList;
261int 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);
285char* kasciitolower(
char *s )
289 for (
unsigned char *p = (
unsigned char *) s; *p; ++p )
290 *p = ( *p >=
'A' && *p <=
'Z' ) ? (*p -
'A' +
'a') : *p;
294char* 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 TDE global objects for use in shared libraries.
TQCString instanceName() const
Returns the name of the instance.
TDELocale provides support for country specific stuff like the national language.
TDEConfig variant using shared memory.
Site-independent access to standard KDE directories.