From dfe289850f068f19ba4a83ab4e7e22a7e09c13c9 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sat, 26 Jan 2013 13:17:21 -0600 Subject: Rename a number of libraries and executables to avoid conflicts with KDE4 --- tdecore/CMakeLists.txt | 12 +- tdecore/DESIGN.iconloading | 6 +- tdecore/MAINTAINERS | 8 +- tdecore/Makefile.am | 12 +- tdecore/README.kiosk | 8 +- tdecore/kaccelmanager.cpp | 2 +- tdecore/kconfig_compiler/Makefile.am | 2 +- tdecore/kconfig_compiler/example/Makefile.am | 4 +- tdecore/kconfig_compiler/tests/Makefile.am | 32 +- .../tests/kconfigcompiler_test.cpp | 4 +- .../kconfig_compiler/tests/kconfigcompiler_test.h | 2 +- tdecore/kdebug.areas | 78 +-- tdecore/kentities.c | 2 +- tdecore/kentities.gperf | 2 +- tdecore/kmultipledrag.cpp | 82 ---- tdecore/kmultipledrag.h | 105 ---- tdecore/kprotocolinfo_tdecore.cpp | 4 +- tdecore/kprotocolinfofactory.cpp | 4 +- tdecore/kprotocolinfofactory.h | 2 +- tdecore/kstringhandler.h | 4 +- tdecore/ksycoca.cpp | 528 --------------------- tdecore/ksycoca.h | 187 -------- tdecore/ksycocadict.cpp | 454 ------------------ tdecore/ksycocadict.h | 123 ----- tdecore/ksycocaentry.h | 123 ----- tdecore/ksycocafactory.cpp | 202 -------- tdecore/ksycocafactory.h | 143 ------ tdecore/ksycocatype.h | 64 --- tdecore/network/CMakeLists.txt | 2 +- tdecore/network/Makefile.am | 4 +- tdecore/network/kmulticastsocket.h | 113 ----- tdecore/network/kmulticastsocketdevice.h | 151 ------ tdecore/network/tdemulticastsocket.h | 113 +++++ tdecore/network/tdemulticastsocketdevice.h | 151 ++++++ tdecore/tdehardwaredevices.cpp | 4 +- tdecore/tdemultipledrag.cpp | 82 ++++ tdecore/tdemultipledrag.h | 105 ++++ tdecore/tdesycoca.cpp | 528 +++++++++++++++++++++ tdecore/tdesycoca.h | 187 ++++++++ tdecore/tdesycocadict.cpp | 454 ++++++++++++++++++ tdecore/tdesycocadict.h | 123 +++++ tdecore/tdesycocaentry.h | 123 +++++ tdecore/tdesycocafactory.cpp | 202 ++++++++ tdecore/tdesycocafactory.h | 143 ++++++ tdecore/tdesycocatype.h | 64 +++ tdecore/tests/Makefile.am | 8 +- tdecore/tests/dcopkonqtest.cpp | 4 +- tdecore/tests/kapptest.cpp | 2 +- tdecore/tests/kconfigtest.cpp | 6 +- 49 files changed, 2384 insertions(+), 2384 deletions(-) delete mode 100644 tdecore/kmultipledrag.cpp delete mode 100644 tdecore/kmultipledrag.h delete mode 100644 tdecore/ksycoca.cpp delete mode 100644 tdecore/ksycoca.h delete mode 100644 tdecore/ksycocadict.cpp delete mode 100644 tdecore/ksycocadict.h delete mode 100644 tdecore/ksycocaentry.h delete mode 100644 tdecore/ksycocafactory.cpp delete mode 100644 tdecore/ksycocafactory.h delete mode 100644 tdecore/ksycocatype.h delete mode 100644 tdecore/network/kmulticastsocket.h delete mode 100644 tdecore/network/kmulticastsocketdevice.h create mode 100644 tdecore/network/tdemulticastsocket.h create mode 100644 tdecore/network/tdemulticastsocketdevice.h create mode 100644 tdecore/tdemultipledrag.cpp create mode 100644 tdecore/tdemultipledrag.h create mode 100644 tdecore/tdesycoca.cpp create mode 100644 tdecore/tdesycoca.h create mode 100644 tdecore/tdesycocadict.cpp create mode 100644 tdecore/tdesycocadict.h create mode 100644 tdecore/tdesycocaentry.h create mode 100644 tdecore/tdesycocafactory.cpp create mode 100644 tdecore/tdesycocafactory.h create mode 100644 tdecore/tdesycocatype.h (limited to 'tdecore') diff --git a/tdecore/CMakeLists.txt b/tdecore/CMakeLists.txt index 2adc73c52..8d4939d83 100644 --- a/tdecore/CMakeLists.txt +++ b/tdecore/CMakeLists.txt @@ -85,9 +85,9 @@ install( FILES kdcoppropertyproxy.h netwm.h kaccelmanager.h netwm_def.h kpixmapprovider.h kunload.h kstaticdeleter.h kextsock.h kextendedsocket.h ksockaddr.h kprocio.h kasyncio.h kbufferedio.h - kurldrag.h kmimesourcefactory.h kmdcodec.h ksocks.h ksycoca.h - ksycocaentry.h ksycocatype.h kxmessages.h kstartupinfo.h - klargefile.h kmultipledrag.h kgenericfactory.h kgenericfactory.tcc + kurldrag.h kmimesourcefactory.h kmdcodec.h ksocks.h tdesycoca.h + tdesycocaentry.h tdesycocatype.h kxmessages.h kstartupinfo.h + klargefile.h tdemultipledrag.h kgenericfactory.h kgenericfactory.tcc ktypelist.h ksortablevaluelist.h kdebugclasses.h kclipboard.h kcalendarsystem.h kcalendarsystemfactory.h kmacroexpander.h kmanagerselection.h kmountpoint.h kuser.h klockfile.h @@ -138,9 +138,9 @@ set( ${target}_SRCS kaudioplayer.cpp kdcoppropertyproxy.cpp ksockaddr.cpp kextsock.cpp netsupp.cpp kprocio.cpp kbufferedio.cpp kpixmapprovider.cpp kurldrag.cpp kmdcodec.cpp ksocks.cpp - fakes.c vsnprintf.c ksycoca.cpp ksycocadict.cpp ksycoca.skel - ksycocafactory.cpp kxmessages.cpp kstartupinfo.cpp - kcatalogue.cpp kasyncio.cpp kmultipledrag.cpp kstaticdeleter.cpp + fakes.c vsnprintf.c tdesycoca.cpp tdesycocadict.cpp tdesycoca.skel + tdesycocafactory.cpp kxmessages.cpp kstartupinfo.cpp + kcatalogue.cpp kasyncio.cpp tdemultipledrag.cpp kstaticdeleter.cpp kappdcopiface.cpp kappdcopiface.skel kclipboard.cpp kcheckaccelerators.cpp tdeversion.cpp kdebugdcopiface.cpp kdebugdcopiface.skel kcalendarsystem.cpp kcalendarsystemgregorian.cpp diff --git a/tdecore/DESIGN.iconloading b/tdecore/DESIGN.iconloading index bcfb13c95..a9e57afbd 100644 --- a/tdecore/DESIGN.iconloading +++ b/tdecore/DESIGN.iconloading @@ -58,7 +58,7 @@ can copy this pixmap: // p contains now 30x30 pixels of test.png. The only hard part is then to publish the icons in a way that applications -know what to copy. I'm thinking about a ksycoca-sort-of index that +know what to copy. I'm thinking about a tdesycoca-sort-of index that applications can map and can use to do fast lookups with. This has no major problems except for the race-condition that might exist when an icon is removed. In that case you will remove it from the index first and then later @@ -79,7 +79,7 @@ sure that the index will no longer be used. I think the best way to distribute the index information is through the file system but the update mechanism for this file should probably more complex -than the one used in ksycoca. Since ksycoca updates only happen once in a +than the one used in tdesycoca. Since tdesycoca updates only happen once in a while, we can afford it to write out a whole new file. For icons this will probably be more difficult since updates will be part of normal operation, if the index file is rather large (no idea about that.. how much icons are in @@ -182,6 +182,6 @@ KDE 2.2: We deliver. oh I see to answer you rfirst question: "won't the ipc be a bottleneck?" no, because you don't use ipc in the critical part (the icon loading) yup I understand how it works now I think - instead you access an index from disk which is quite fast (as fast as ksycoca) + instead you access an index from disk which is quite fast (as fast as tdesycoca) I think this will definitely speed things up on my machine since I have a relatively fast box with slow disks that's why I want to use the file-system instaed of X-properties diff --git a/tdecore/MAINTAINERS b/tdecore/MAINTAINERS index 07a996b24..995ab753a 100644 --- a/tdecore/MAINTAINERS +++ b/tdecore/MAINTAINERS @@ -44,7 +44,7 @@ klibloader.cpp klocale.cpp Hans Petter Bieker kmdcodec.cpp kmimesourcefactory.cpp -kmultipledrag.cpp David Faure +tdemultipledrag.cpp David Faure knotifyclient.cpp kpalette.cpp Waldo Bastian kpixmapprovider.cpp Carsten Pfeiffer @@ -64,9 +64,9 @@ kstartupinfo.cpp Lubos Lunak kstaticdeleter.cpp Stephan Kulow kstdaccel.cpp Ellis Whitehead kstringhandler.cpp -ksycoca.cpp Waldo Bastian -ksycocadict.cpp Waldo Bastian -ksycocafactory.cpp Waldo Bastian +tdesycoca.cpp Waldo Bastian +tdesycocadict.cpp Waldo Bastian +tdesycocafactory.cpp Waldo Bastian ktempfile.cpp Waldo Bastian kuniqueapplication.cpp Waldo Bastian kurl.cpp Waldo Bastian diff --git a/tdecore/Makefile.am b/tdecore/Makefile.am index f8856108c..75037eccf 100644 --- a/tdecore/Makefile.am +++ b/tdecore/Makefile.am @@ -53,8 +53,8 @@ include_HEADERS = kconfig.h kconfigskeleton.h \ netwm_def.h kpixmapprovider.h kunload.h kstaticdeleter.h \ kextsock.h kextendedsocket.h ksockaddr.h kprocio.h kasyncio.h \ kbufferedio.h kurldrag.h kmimesourcefactory.h kmdcodec.h ksocks.h \ - ksycoca.h ksycocaentry.h ksycocatype.h kxmessages.h kstartupinfo.h \ - klargefile.h kmultipledrag.h kgenericfactory.h kgenericfactory.tcc \ + tdesycoca.h tdesycocaentry.h tdesycocatype.h kxmessages.h kstartupinfo.h \ + klargefile.h tdemultipledrag.h kgenericfactory.h kgenericfactory.tcc \ ktypelist.h ksortablevaluelist.h kdebugclasses.h kclipboard.h \ kcalendarsystem.h kcalendarsystemfactory.h kmacroexpander.h \ kmanagerselection.h kmountpoint.h kuser.h klockfile.h \ @@ -84,7 +84,7 @@ libtdefakes_pic.a: libtdefakes.la noinst_HEADERS = kaccelaction.h kaccelbase.h kaccelprivate.h kckey.h \ kcompletion_private.h netwm_p.h \ kglobalaccel_x11.h kglobalaccel_win.h kkeyserver_x11.h kkeyserver.h \ - kregpriv.h kshortcutmenu.h ksycocadict.h ksycocafactory.h netsupp.h \ + kregpriv.h kshortcutmenu.h tdesycocadict.h tdesycocafactory.h netsupp.h \ kcheckaccelerators.h kcalendarsystemgregorian.h \ kcalendarsystemhijri.h kcalendarsystemhebrew.h kcalendarsystemjalali.h \ kprotocolinfofactory.h kqiodevicegzip_p.h kiconloader_p.h @@ -108,9 +108,9 @@ libtdecore_la_SOURCES = libintl.cpp kapplication.cpp \ ksockaddr.cpp kextsock.cpp netsupp.cpp kprocio.cpp kbufferedio.cpp \ kpixmapprovider.cpp kurldrag.cpp \ kmdcodec.cpp ksocks.cpp fakes.c vsnprintf.c \ - ksycoca.cpp ksycocadict.cpp ksycocafactory.cpp ksycoca.skel \ + tdesycoca.cpp tdesycocadict.cpp tdesycocafactory.cpp tdesycoca.skel \ kxmessages.cpp kstartupinfo.cpp kcatalogue.cpp kasyncio.cpp \ - kmultipledrag.cpp kstaticdeleter.cpp kappdcopiface.cpp \ + tdemultipledrag.cpp kstaticdeleter.cpp kappdcopiface.cpp \ kappdcopiface.skel kclipboard.cpp kcheckaccelerators.cpp \ tdeversion.cpp kdebugdcopiface.cpp kdebugdcopiface.skel \ kcalendarsystem.cpp kcalendarsystemgregorian.cpp \ @@ -188,7 +188,7 @@ install-exec-hook: DISTCLEANFILES = tde-config.cpp -DOXYGEN_REFERENCES = dcop tdeui kparts kio +DOXYGEN_REFERENCES = dcop tdeui tdeparts kio DOXYGEN_EXCLUDE = malloc kde_file.h DOXYGEN_SET_WARN_IF_UNDOCUMENTED = YES diff --git a/tdecore/README.kiosk b/tdecore/README.kiosk index 635c61f95..657a6a72b 100644 --- a/tdecore/README.kiosk +++ b/tdecore/README.kiosk @@ -492,11 +492,11 @@ of these actions then the application will not appear in the TDE menu and will n be used by KDE for opening files. IMPORTANT NOTE: -Changing restrictions may influence the data that is cached in the ksycoca +Changing restrictions may influence the data that is cached in the tdesycoca database. Since changes to .../share/config/kdeglobals do not trigger an -automatic ksycoca update you need to force an update manually. -To force an update of the ksycoca database touch the file -.../share/services/update_ksycoca. This will force a user's sycoca database +automatic tdesycoca update you need to force an update manually. +To force an update of the tdesycoca database touch the file +.../share/services/update_tdesycoca. This will force a user's sycoca database to be rebuild the next time the user logs in. KDE3 URL Restrictions diff --git a/tdecore/kaccelmanager.cpp b/tdecore/kaccelmanager.cpp index d4387e652..6c2233c81 100644 --- a/tdecore/kaccelmanager.cpp +++ b/tdecore/kaccelmanager.cpp @@ -47,7 +47,7 @@ #include "kaccelmanager_private.h" #include "../tdeui/kstdaction_p.h" -#include "../kutils/kmultitabbar.h" +#include "../tdeutils/tdemultitabbar.h" /********************************************************************* diff --git a/tdecore/kconfig_compiler/Makefile.am b/tdecore/kconfig_compiler/Makefile.am index 5a3b0f2e8..d4f287381 100644 --- a/tdecore/kconfig_compiler/Makefile.am +++ b/tdecore/kconfig_compiler/Makefile.am @@ -4,7 +4,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/tdecore -I$(top_srcdir) $(all_includes) bin_PROGRAMS = kconfig_compiler -kconfig_compiler_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -lktexteditor +kconfig_compiler_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor kconfig_compiler_LDADD = $(LIB_TDECORE) kconfig_compiler_SOURCES = kconfig_compiler.cpp diff --git a/tdecore/kconfig_compiler/example/Makefile.am b/tdecore/kconfig_compiler/example/Makefile.am index f7834ba63..4e7a59fec 100644 --- a/tdecore/kconfig_compiler/example/Makefile.am +++ b/tdecore/kconfig_compiler/example/Makefile.am @@ -3,11 +3,11 @@ AM_CPPFLAGS = -I$(top_srcdir)/tdecore -I$(top_srcdir) $(all_includes) check_PROGRAMS = example # autoexample EXTRA_PROGRAMS = autoexample -example_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -lktexteditor +example_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor example_LDADD = $(LIB_TDECORE) example_SOURCES = example.cpp exampleprefs_base.cpp -autoexample_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -lktexteditor +autoexample_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor autoexample_LDADD = $(LIB_TDECORE) $(LIB_TDEUI) autoexample_SOURCES = exampleprefs_base.cpp general_base.ui myoptions_base.ui \ autoexample.cpp diff --git a/tdecore/kconfig_compiler/tests/Makefile.am b/tdecore/kconfig_compiler/tests/Makefile.am index 9462c800b..953d1c6b4 100644 --- a/tdecore/kconfig_compiler/tests/Makefile.am +++ b/tdecore/kconfig_compiler/tests/Makefile.am @@ -1,4 +1,4 @@ -AM_CPPFLAGS = -I$(top_srcdir)/tdecore -I$(top_srcdir)/kunittest $(all_includes) -DQT_NO_CAST_ASCII -DSRCDIR=\"$(srcdir)\" +AM_CPPFLAGS = -I$(top_srcdir)/tdecore -I$(top_srcdir)/tdeunittest $(all_includes) -DQT_NO_CAST_ASCII -DSRCDIR=\"$(srcdir)\" check_PROGRAMS = test1 test2 test3 test4 test5 test6 test7 test8 test9 test_dpointer @@ -14,52 +14,52 @@ CLEANFILES = test1.cpp test1.h \ test_dpointer.cpp test_dpointer.h \ md5sums -test1_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -lktexteditor +test1_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor test1_LDADD = $(LIB_TDECORE) test1_SOURCES = test1main.cpp test1.cpp -test2_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -lktexteditor +test2_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor test2_LDADD = $(LIB_TDECORE) test2_SOURCES = test2main.cpp test2.cpp -test3_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -lktexteditor +test3_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor test3_LDADD = $(LIB_TDECORE) test3_SOURCES = test3main.cpp test3.cpp -test4_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -lktexteditor +test4_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor test4_LDADD = $(LIB_TDECORE) test4_SOURCES = test4main.cpp test4.cpp -test5_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -lktexteditor +test5_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor test5_LDADD = $(LIB_TDECORE) test5_SOURCES = test5main.cpp test5.cpp -test6_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -lktexteditor +test6_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor test6_LDADD = $(LIB_TDECORE) test6_SOURCES = test6main.cpp test6.cpp -test7_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -lktexteditor +test7_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor test7_LDADD = $(LIB_TDECORE) test7_SOURCES = test7main.cpp test7.cpp -test8_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -lktexteditor +test8_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor test8_LDADD = $(LIB_TDECORE) test8_SOURCES = test8main.cpp test8a.cpp test8b.cpp -test9_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -lktexteditor +test9_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor test9_LDADD = $(LIB_TDECORE) test9_SOURCES = test9main.cpp test9.cpp -test_dpointer_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -lktexteditor +test_dpointer_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor test_dpointer_LDADD = $(LIB_TDECORE) test_dpointer_SOURCES = test_dpointer_main.cpp test_dpointer.cpp -check_LTLIBRARIES = kunittest_kconfigcompiler_test.la +check_LTLIBRARIES = tdeunittest_kconfigcompiler_test.la -kunittest_kconfigcompiler_test_la_SOURCES = kconfigcompiler_test.cpp -kunittest_kconfigcompiler_test_la_LIBADD = \ - $(top_builddir)/kunittest/libkunittest.la -kunittest_kconfigcompiler_test_la_LDFLAGS = -module $(KDE_CHECK_PLUGIN) \ +tdeunittest_kconfigcompiler_test_la_SOURCES = kconfigcompiler_test.cpp +tdeunittest_kconfigcompiler_test_la_LIBADD = \ + $(top_builddir)/tdeunittest/libtdeunittest.la +tdeunittest_kconfigcompiler_test_la_LDFLAGS = -module $(KDE_CHECK_PLUGIN) \ $(all_libraries) diff --git a/tdecore/kconfig_compiler/tests/kconfigcompiler_test.cpp b/tdecore/kconfig_compiler/tests/kconfigcompiler_test.cpp index 143838908..c9f2f8471 100644 --- a/tdecore/kconfig_compiler/tests/kconfigcompiler_test.cpp +++ b/tdecore/kconfig_compiler/tests/kconfigcompiler_test.cpp @@ -16,12 +16,12 @@ #include #include #include -#include +#include #include "kconfigcompiler_test.h" using namespace KUnitTest; -KUNITTEST_MODULE( kunittest_kconfigcompiler_test, "TDEConfigXT") +KUNITTEST_MODULE( tdeunittest_kconfigcompiler_test, "TDEConfigXT") KUNITTEST_MODULE_REGISTER_TESTER( TDEConfigCompiler_Test ) typedef const char * CompilerTestSet[]; diff --git a/tdecore/kconfig_compiler/tests/kconfigcompiler_test.h b/tdecore/kconfig_compiler/tests/kconfigcompiler_test.h index 1eba78b97..df3f4cf37 100644 --- a/tdecore/kconfig_compiler/tests/kconfigcompiler_test.h +++ b/tdecore/kconfig_compiler/tests/kconfigcompiler_test.h @@ -16,7 +16,7 @@ #ifndef KCONFIGCOMPILER_TEST_H #define KCONFIGCOMPILER_TEST_H -#include +#include class TQString; diff --git a/tdecore/kdebug.areas b/tdecore/kdebug.areas index 92e62aaee..f2da61c43 100644 --- a/tdecore/kdebug.areas +++ b/tdecore/kdebug.areas @@ -47,27 +47,27 @@ 399 kimgio 400 artskde 500 tdeprint -700 kutils (KSettings::Dialog) -701 kutils (KSettings::Dispatcher) -702 kutils (KPluginSelector) -703 kutils (KPluginInfo) -704 kutils (KSettings::ComponentsDialog) -710 kutils (KCMultiDialog) -711 kutils (TDECModuleProxy) -712 kutils (TDECModuleInfo) -713 kutils (TDECModuleContainer) -750 kspell (tdelibs) -760 kmdi +700 tdeutils (KSettings::Dialog) +701 tdeutils (KSettings::Dispatcher) +702 tdeutils (KPluginSelector) +703 tdeutils (KPluginInfo) +704 tdeutils (KSettings::ComponentsDialog) +710 tdeutils (KCMultiDialog) +711 tdeutils (TDECModuleProxy) +712 tdeutils (TDECModuleInfo) +713 tdeutils (TDECModuleContainer) +750 tdespell (tdelibs) +760 tdemdi 780 kcmshell (tdelibs) -790 kimproxy (tdelibs) +790 tdeimproxy (tdelibs) 800 kabapi (tdelibs) 900 tdesu (tdelibs) 912 ksmartcard (tdelibs) -1000 kparts -1001 kparts (mainwindow) -1002 kparts (factory) +1000 tdeparts +1001 tdeparts (mainwindow) +1002 tdeparts (factory) # tdebase 1201 konqtree @@ -116,7 +116,7 @@ 2003 ksim 2100 kgpg 2200 kdf -2300 kwallet +2300 tdewallet # 2500-2999 Reserved for private use @@ -182,7 +182,7 @@ 5600 kontact (core) 5601 kontact (interfaces) 5602 kontact (plugins) -5650 kresources +5650 tderesources 5700 kabc 5710 kabc/vcard 5720 kaddressbook @@ -197,28 +197,28 @@ 5960 kandy 5970 karm -# libkhtml -6000 khtml -6005 khtml (encoding) -6010 khtml (dom) -6020 khtml (xml) -6030 khtml (html) -6031 khtml (frames & objects) -6035 khtml (parser) -6036 khtml (tokenizer) -6040 khtml (render) -6041 khtml (bidi) -6045 khtml (rendering tree) -6050 khtml (part) -6060 khtml (cache) -6061 khtml (cache-expiredates) -6070 khtml (jscript) -6080 khtml (css) -6090 khtml (memory) +# libtdehtml +6000 tdehtml +6005 tdehtml (encoding) +6010 tdehtml (dom) +6020 tdehtml (xml) +6030 tdehtml (html) +6031 tdehtml (frames & objects) +6035 tdehtml (parser) +6036 tdehtml (tokenizer) +6040 tdehtml (render) +6041 tdehtml (bidi) +6045 tdehtml (rendering tree) +6050 tdehtml (part) +6060 tdehtml (cache) +6061 tdehtml (cache-expiredates) +6070 tdehtml (jscript) +6080 tdehtml (css) +6090 tdehtml (memory) 6100 kjas -6200 khtml (caret) -6201 khtml (caret table) -6210 khtml (editor) +6200 tdehtml (caret) +6201 tdehtml (caret table) +6210 tdehtml (editor) # libkio 7000 kio @@ -556,7 +556,7 @@ 66666 noatun 67000 kscd 67100 kmix -67200 kmid +67200 tdemid # tdebindings 70001 dcoppython diff --git a/tdecore/kentities.c b/tdecore/kentities.c index 8181e5a6c..141ed9db0 100644 --- a/tdecore/kentities.c +++ b/tdecore/kentities.c @@ -53,7 +53,7 @@ kentities.gperf: input file to generate a hash table for entities kentities.c: DO NOT EDIT! generated by the command - "gperf -a -L "ANSI-C" -C -G -c -o -t -k '*' -Nkde_findEntity -D -s 2 khtmlentities.gperf > entities.c" + "gperf -a -L "ANSI-C" -C -G -c -o -t -k '*' -Nkde_findEntity -D -s 2 tdehtmlentities.gperf > entities.c" from kentities.gperf $Id$ diff --git a/tdecore/kentities.gperf b/tdecore/kentities.gperf index 08f712707..5d848b837 100644 --- a/tdecore/kentities.gperf +++ b/tdecore/kentities.gperf @@ -22,7 +22,7 @@ kentities.gperf: input file to generate a hash table for entities kentities.c: DO NOT EDIT! generated by the command - "gperf -a -L "ANSI-C" -C -G -c -o -t -k '*' -Nkde_findEntity -D -s 2 khtmlentities.gperf > entities.c" + "gperf -a -L "ANSI-C" -C -G -c -o -t -k '*' -Nkde_findEntity -D -s 2 tdehtmlentities.gperf > entities.c" from kentities.gperf $Id$ diff --git a/tdecore/kmultipledrag.cpp b/tdecore/kmultipledrag.cpp deleted file mode 100644 index 29d56bd85..000000000 --- a/tdecore/kmultipledrag.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2001 David Faure - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this program; see the file COPYING. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "kmultipledrag.h" -#include "kdebug.h" - -#ifndef QT_NO_DRAGANDDROP - -KMultipleDrag::KMultipleDrag( TQWidget *dragSource, const char *name ) - : TQDragObject( dragSource, name ) -{ - m_dragObjects.setAutoDelete( true ); -} - -void KMultipleDrag::addDragObject( TQDragObject *dragObject ) -{ - //kdDebug() << "KMultipleDrag::addDragObject" << endl; - m_dragObjects.append( dragObject ); - // We need to find out how many formats this dragObject supports - int i = 0; - while ( dragObject->format( i ) ) - ++i; - m_numberFormats.append( i ); // e.g. if it supports two formats, 0 and 1, store 2. -} - -TQByteArray KMultipleDrag::encodedData( const char *mime ) const -{ - //kdDebug() << "KMultipleDrag::encodedData " << mime << endl; - // Iterate over the drag objects, and find the format in the right one - TQPtrListIterator it( m_dragObjects ); - for ( ; it.current(); ++it ) - { - for ( int i = 0; it.current()->format( i ); ++i ) - { - if ( ::qstrcmp( it.current()->format( i ), mime ) == 0 ) - return it.current()->encodedData( mime ); - } - } - return TQByteArray(); -} - -const char* KMultipleDrag::format( int i ) const -{ - //kdDebug() << "KMultipleDrag::format " << i << endl; - // example: m_numberFormats: 1, 4 - // m_dragObjects: storeddrag, textdrag - // i=0 -> storeddrag->format( 0 ) - // i=1 -> textdrag->format( 0 ) - // i=2 -> textdrag->format( 1 ) - // etc. - TQValueList::ConstIterator nit = m_numberFormats.begin(); - TQValueList::ConstIterator nend = m_numberFormats.end(); - TQPtrListIterator it( m_dragObjects ); - for ( ; nit != nend && i >= *nit ; ++nit, ++it ) - i -= *nit; - if ( it.current() ) - return it.current()->format( i ); - return 0; -} - -void KMultipleDrag::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } - -#include "kmultipledrag.moc" - -#endif diff --git a/tdecore/kmultipledrag.h b/tdecore/kmultipledrag.h deleted file mode 100644 index 42baf3530..000000000 --- a/tdecore/kmultipledrag.h +++ /dev/null @@ -1,105 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2001 David Faure - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this program; see the file COPYING. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef KMULTIPLEDRAG_H -#define KMULTIPLEDRAG_H - -#ifndef QT_NO_DRAGANDDROP - -#include -#include -#include "tdelibs_export.h" - -class KMultipleDragPrivate; -/** - * This class makes it easy for applications to provide a drag object - * (for drag-n-drop or for clipboard) that has several representations - * of the same data, under different formats. - * - * Instead of creating a specific class for each case (as would otherwise - * be necessary), you can simply create independent drag objects (e.g. - * a TQImageDrag object and a KURLDrag object), and bundle them together - * using KMultipleDrag. - * - * Sample code for this: - * - * \code - * KMultipleDrag *drag = new KMultipleDrag( parentWidget ); - * drag->addDragObject( new TQImageDrag( someQImage, 0 ) ); - * drag->addDragObject( new KURLDrag( someKURL, 0 ) ); - * drag->drag(); - * \endcode - * - * Note that the drag objects added to the multiple drag become owned by it. - * For that reason their parent should be 0. - * - * @author David Faure - */ -class TDECORE_EXPORT KMultipleDrag : public TQDragObject -{ - Q_OBJECT - -public: - /** - * Create a new KMultipleDrag object. - * @param dragSource the parent object which is the source of the data, - * 0 for a parent-less object - * @param name the name of the object, can be 0 - */ - KMultipleDrag( TQWidget *dragSource = 0, const char *name = 0 ); - - /** - * Call this to add each underlying drag object to the multiple drag object. - * The drag object should not have a parent because the multiple drag object - * will own it. - * - * @param dragObject the drag object to add. Should have no parent object. - */ - void addDragObject( TQDragObject *dragObject ); - - /** - * Returns the data of a drag object with that supports the given - * mime type. - * @param mime the mime type to search - * @return the data, or a null byte array if not found - * @reimp - */ - virtual TQByteArray encodedData( const char *mime ) const; - - /** - * Returns the @p i'th supported format, or 0. - * @param i the number of the format to check - * @return the format with the number @p i, or 0 otherwise - * @reimp - */ - virtual const char* format( int i ) const; - -protected: -// KDE4: make private - TQPtrList m_dragObjects; - TQValueList m_numberFormats; -protected: - virtual void virtual_hook( int id, void* data ); -private: - KMultipleDragPrivate* d; -}; - -#endif // QT_NO_DRAGANDDROP - -#endif // KMULTIPLEDRAG_H diff --git a/tdecore/kprotocolinfo_tdecore.cpp b/tdecore/kprotocolinfo_tdecore.cpp index 1c6232068..de16f0128 100644 --- a/tdecore/kprotocolinfo_tdecore.cpp +++ b/tdecore/kprotocolinfo_tdecore.cpp @@ -150,7 +150,7 @@ void KProtocolInfo::load( TQDataStream& _str) { // You may add new fields at the end. Make sure to update the version - // number in ksycoca.h + // number in tdesycoca.h TQ_INT32 i_inputType, i_outputType; TQ_INT8 i_isSourceProtocol, i_isHelperProtocol, i_supportsListing, i_supportsReading, @@ -205,7 +205,7 @@ KProtocolInfo::save( TQDataStream& _str) KSycocaEntry::save( _str ); // You may add new fields at the end. Make sure to update the version - // number in ksycoca.h + // number in tdesycoca.h TQ_INT32 i_inputType, i_outputType; TQ_INT8 i_isSourceProtocol, i_isHelperProtocol, i_supportsListing, i_supportsReading, diff --git a/tdecore/kprotocolinfofactory.cpp b/tdecore/kprotocolinfofactory.cpp index e47cbb881..c651024ef 100644 --- a/tdecore/kprotocolinfofactory.cpp +++ b/tdecore/kprotocolinfofactory.cpp @@ -21,8 +21,8 @@ #include #include #include -#include -#include +#include +#include #include "kprotocolinfofactory.h" diff --git a/tdecore/kprotocolinfofactory.h b/tdecore/kprotocolinfofactory.h index 6a10ac1e3..04883bde0 100644 --- a/tdecore/kprotocolinfofactory.h +++ b/tdecore/kprotocolinfofactory.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include class KProtocolInfoPrivate; diff --git a/tdecore/kstringhandler.h b/tdecore/kstringhandler.h index 40cfa3617..f20963d63 100644 --- a/tdecore/kstringhandler.h +++ b/tdecore/kstringhandler.h @@ -350,8 +350,8 @@ public: * * Example: * \code - * perlSplit(' ', "kparts reaches the parts other parts can't", 3) - * TQStringList contains: "kparts", "reaches", "the parts other parts can't" + * perlSplit(' ', "tdeparts reaches the parts other parts can't", 3) + * TQStringList contains: "tdeparts", "reaches", "the parts other parts can't" * \endcode * * @param sep is the character to use to delimit s. diff --git a/tdecore/ksycoca.cpp b/tdecore/ksycoca.cpp deleted file mode 100644 index 0a2cd2511..000000000 --- a/tdecore/ksycoca.cpp +++ /dev/null @@ -1,528 +0,0 @@ -/* This file is part of the KDE libraries - * Copyright (C) 1999-2000 Waldo Bastian - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License version 2 as published by the Free Software Foundation; - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - **/ - -#include "config.h" - -#include "ksycoca.h" -#include "ksycocatype.h" -#include "ksycocafactory.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#ifdef HAVE_SYS_MMAN_H -#include -#endif - -#ifdef Q_OS_SOLARIS -extern "C" -{ - extern int madvise(caddr_t, size_t, int); -} -#endif - -#ifndef MAP_FAILED -#define MAP_FAILED ((void *) -1) -#endif - -template class TQPtrList; - -// The following limitations are in place: -// Maximum length of a single string: 8192 bytes -// Maximum length of a string list: 1024 strings -// Maximum number of entries: 8192 -// -// The purpose of these limitations is to limit the impact -// of database corruption. - -class KSycocaPrivate { -public: - KSycocaPrivate() { - database = 0; - readError = false; - updateSig = 0; - autoRebuild = true; - } - TQFile *database; - TQStringList changeList; - TQString language; - bool readError; - bool autoRebuild; - TQ_UINT32 updateSig; - TQStringList allResourceDirs; -}; - -int KSycoca::version() -{ - return KSYCOCA_VERSION; -} - -// Read-only constructor -KSycoca::KSycoca() - : DCOPObject("ksycoca"), m_lstFactories(0), m_str(0), m_barray(0), bNoDatabase(false), - m_sycoca_size(0), m_sycoca_mmap(0), m_timeStamp(0) -{ - d = new KSycocaPrivate; - // Register app as able to receive DCOP messages - if (kapp && !kapp->dcopClient()->isAttached()) - { - kapp->dcopClient()->attach(); - } - // We register with DCOP _before_ we try to open the database. - // This way we can be relative sure that the KDE framework is - // up and running (tdeinit, dcopserver, klaucnher, kded) and - // that the database is up to date. - openDatabase(); - _self = this; -} - -bool KSycoca::openDatabase( bool openDummyIfNotFound ) -{ - bool result = true; - - m_sycoca_mmap = 0; - m_str = 0; - m_barray = 0; - TQString path; - TQCString ksycoca_env = getenv("TDESYCOCA"); - if (ksycoca_env.isEmpty()) - path = TDEGlobal::dirs()->saveLocation("cache") + "ksycoca"; - else - path = TQFile::decodeName(ksycoca_env); - - kdDebug(7011) << "Trying to open ksycoca from " << path << endl; - TQFile *database = new TQFile(path); - bool bOpen = database->open( IO_ReadOnly ); - if (!bOpen) - { - path = locate("services", "ksycoca"); - if (!path.isEmpty()) - { - kdDebug(7011) << "Trying to open global ksycoca from " << path << endl; - delete database; - database = new TQFile(path); - bOpen = database->open( IO_ReadOnly ); - } - } - - if (bOpen) - { - fcntl(database->handle(), F_SETFD, FD_CLOEXEC); - m_sycoca_size = database->size(); -#ifdef HAVE_MMAP - m_sycoca_mmap = (const char *) mmap(0, m_sycoca_size, - PROT_READ, MAP_SHARED, - database->handle(), 0); - /* POSIX mandates only MAP_FAILED, but we are paranoid so check for - null pointer too. */ - if (m_sycoca_mmap == (const char*) MAP_FAILED || m_sycoca_mmap == 0) - { - kdDebug(7011) << "mmap failed. (length = " << m_sycoca_size << ")" << endl; -#endif - m_str = new TQDataStream(database); -#ifdef HAVE_MMAP - } - else - { -#ifdef HAVE_MADVISE - (void) madvise((char*)m_sycoca_mmap, m_sycoca_size, MADV_WILLNEED); -#endif - m_barray = new TQByteArray(); - m_barray->setRawData(m_sycoca_mmap, m_sycoca_size); - TQBuffer *buffer = new TQBuffer( *m_barray ); - buffer->open(IO_ReadWrite); - m_str = new TQDataStream( buffer); - } -#endif - bNoDatabase = false; - } - else - { - kdDebug(7011) << "Could not open ksycoca" << endl; - - // No database file - delete database; - database = 0; - - bNoDatabase = true; - if (openDummyIfNotFound) - { - // We open a dummy database instead. - //kdDebug(7011) << "No database, opening a dummy one." << endl; - TQBuffer *buffer = new TQBuffer(); - buffer->setBuffer(TQByteArray()); - buffer->open(IO_ReadWrite); - m_str = new TQDataStream( buffer); - (*m_str) << (TQ_INT32) KSYCOCA_VERSION; - (*m_str) << (TQ_INT32) 0; - } - else - { - result = false; - } - } - m_lstFactories = new KSycocaFactoryList(); - m_lstFactories->setAutoDelete( true ); - d->database = database; - return result; -} - -// Read-write constructor - only for KBuildSycoca -KSycoca::KSycoca( bool /* dummy */ ) - : DCOPObject("ksycoca_building"), m_lstFactories(0), m_str(0), m_barray(0), bNoDatabase(false), - m_sycoca_size(0), m_sycoca_mmap(0) -{ - d = new KSycocaPrivate; - m_lstFactories = new KSycocaFactoryList(); - m_lstFactories->setAutoDelete( true ); - _self = this; -} - -static void delete_ksycoca_self() { - delete KSycoca::_self; -} - -KSycoca * KSycoca::self() -{ - if (!_self) { - tqAddPostRoutine(delete_ksycoca_self); - _self = new KSycoca(); - } - return _self; -} - -KSycoca::~KSycoca() -{ - closeDatabase(); - delete d; - _self = 0L; -} - -void KSycoca::closeDatabase() -{ - QIODevice *device = 0; - if (m_str) - device = m_str->device(); -#ifdef HAVE_MMAP - if (device && m_sycoca_mmap) - { - TQBuffer *buf = static_cast(device); - buf->buffer().resetRawData(m_sycoca_mmap, m_sycoca_size); - // Solaris has munmap(char*, size_t) and everything else should - // be happy with a char* for munmap(void*, size_t) - munmap((char*) m_sycoca_mmap, m_sycoca_size); - m_sycoca_mmap = 0; - } -#endif - - delete m_str; - m_str = 0; - delete device; - if (TQT_TQIODEVICE(d->database) != device) - delete d->database; - if (m_barray) delete m_barray; - m_barray = 0; - device = 0; - d->database = 0; - // It is very important to delete all factories here - // since they cache information about the database file - delete m_lstFactories; - m_lstFactories = 0L; -} - -void KSycoca::addFactory( KSycocaFactory *factory ) -{ - assert(m_lstFactories); - m_lstFactories->append(factory); -} - -bool KSycoca::isChanged(const char *type) -{ - return self()->d->changeList.contains(type); -} - -void KSycoca::notifyDatabaseChanged(const TQStringList &changeList) -{ - d->changeList = changeList; - //kdDebug(7011) << "got a notifyDatabaseChanged signal !" << endl; - // kded tells us the database file changed - // Close the database and forget all about what we knew - // The next call to any public method will recreate - // everything that's needed. - closeDatabase(); - - // Now notify applications - emit databaseChanged(); -} - -TQDataStream * KSycoca::findEntry(int offset, KSycocaType &type) -{ - if ( !m_str ) - openDatabase(); - //kdDebug(7011) << TQString("KSycoca::_findEntry(offset=%1)").arg(offset,8,16) << endl; - m_str->device()->at(offset); - TQ_INT32 aType; - (*m_str) >> aType; - type = (KSycocaType) aType; - //kdDebug(7011) << TQString("KSycoca::found type %1").arg(aType) << endl; - return m_str; -} - -bool KSycoca::checkVersion(bool abortOnError) -{ - if ( !m_str ) - { - if( !openDatabase(false /* don't open dummy db if not found */) ) - return false; // No database found - - // We should never get here... if a database was found then m_str shouldn't be 0L. - assert(m_str); - } - m_str->device()->at(0); - TQ_INT32 aVersion; - (*m_str) >> aVersion; - if ( aVersion < KSYCOCA_VERSION ) - { - kdWarning(7011) << "Found version " << aVersion << ", expecting version " << KSYCOCA_VERSION << " or higher." << endl; - if (!abortOnError) return false; - kdError(7011) << "Outdated database ! Stop kded and restart it !" << endl; - abort(); - } - return true; -} - -TQDataStream * KSycoca::findFactory(KSycocaFactoryId id) -{ - // The constructor found no database, but we want one - if (bNoDatabase) - { - closeDatabase(); // close the dummy one - // Check if new database already available - if ( !openDatabase(false /* no dummy one*/) ) - { - static bool triedLaunchingKdeinit = false; - if (!triedLaunchingKdeinit) // try only once - { - triedLaunchingKdeinit = true; - kdDebug(7011) << "findFactory: we have no database.... launching tdeinit" << endl; - TDEApplication::startKdeinit(); - // Ok, the new database should be here now, open it. - } - if (!openDatabase(false)) - return 0L; // Still no database - uh oh - } - } - // rewind and check - if (!checkVersion(false)) - { - kdWarning(7011) << "Outdated database found" << endl; - return 0L; - } - TQ_INT32 aId; - TQ_INT32 aOffset; - while(true) - { - (*m_str) >> aId; - //kdDebug(7011) << TQString("KSycoca::findFactory : found factory %1").arg(aId) << endl; - if (aId == 0) - { - kdError(7011) << "Error, KSycocaFactory (id = " << int(id) << ") not found!" << endl; - break; - } - (*m_str) >> aOffset; - if (aId == id) - { - //kdDebug(7011) << TQString("KSycoca::findFactory(%1) offset %2").arg((int)id).arg(aOffset) << endl; - m_str->device()->at(aOffset); - return m_str; - } - } - return 0; -} - -TQString KSycoca::kfsstnd_prefixes() -{ - if (bNoDatabase) return ""; - if (!checkVersion(false)) return ""; - TQ_INT32 aId; - TQ_INT32 aOffset; - // skip factories offsets - while(true) - { - (*m_str) >> aId; - if ( aId ) - (*m_str) >> aOffset; - else - break; // just read 0 - } - // We now point to the header - TQString prefixes; - KSycocaEntry::read(*m_str, prefixes); - (*m_str) >> m_timeStamp; - KSycocaEntry::read(*m_str, d->language); - (*m_str) >> d->updateSig; - KSycocaEntry::read(*m_str, d->allResourceDirs); - return prefixes; -} - -TQ_UINT32 KSycoca::timeStamp() -{ - if (!m_timeStamp) - (void) kfsstnd_prefixes(); - return m_timeStamp; -} - -TQ_UINT32 KSycoca::updateSignature() -{ - if (!m_timeStamp) - (void) kfsstnd_prefixes(); - return d->updateSig; -} - -TQString KSycoca::language() -{ - if (d->language.isEmpty()) - (void) kfsstnd_prefixes(); - return d->language; -} - -TQStringList KSycoca::allResourceDirs() -{ - if (!m_timeStamp) - (void) kfsstnd_prefixes(); - return d->allResourceDirs; -} - -TQString KSycoca::determineRelativePath( const TQString & _fullpath, const char *_resource ) -{ - TQString sRelativeFilePath; - TQStringList dirs = TDEGlobal::dirs()->resourceDirs( _resource ); - TQStringList::ConstIterator dirsit = dirs.begin(); - for ( ; dirsit != dirs.end() && sRelativeFilePath.isEmpty(); ++dirsit ) { - // might need canonicalPath() ... - if ( _fullpath.find( *dirsit ) == 0 ) // path is dirs + relativePath - sRelativeFilePath = _fullpath.mid( (*dirsit).length() ); // skip appsdirs - } - if ( sRelativeFilePath.isEmpty() ) - kdFatal(7011) << TQString(TQString("Couldn't find %1 in any %2 dir !!!").arg( _fullpath ).arg( _resource)) << endl; - //else - // debug code - //kdDebug(7011) << sRelativeFilePath << endl; - return sRelativeFilePath; -} - -KSycoca * KSycoca::_self = 0L; - -void KSycoca::flagError() -{ - tqWarning("ERROR: KSycoca database corruption!"); - if (_self) - { - if (_self->d->readError) - return; - _self->d->readError = true; - if (_self->d->autoRebuild) - if(system("kbuildsycoca") < 0) // Rebuild the damned thing. - tqWarning("ERROR: Running KSycoca failed."); - } -} - -void KSycoca::disableAutoRebuild() -{ - d->autoRebuild = false; -} - -bool KSycoca::readError() -{ - bool b = false; - if (_self) - { - b = _self->d->readError; - _self->d->readError = false; - } - return b; -} - -void KSycocaEntry::read( TQDataStream &s, TQString &str ) -{ - TQ_UINT32 bytes; - s >> bytes; // read size of string - if ( bytes > 8192 ) { // null string or too big - if (bytes != 0xffffffff) - KSycoca::flagError(); - str = TQString::null; - } - else if ( bytes > 0 ) { // not empty - int bt = bytes/2; - str.setLength( bt ); - TQChar* ch = (TQChar *) str.unicode(); - char t[8192]; - char *b = t; - s.readRawBytes( b, bytes ); - while ( bt-- ) { - *ch++ = (ushort) (((ushort)b[0])<<8) | (uchar)b[1]; - b += 2; - } - } else { - str = ""; - } -} - -void KSycocaEntry::read( TQDataStream &s, TQStringList &list ) -{ - list.clear(); - TQ_UINT32 count; - s >> count; // read size of list - if (count >= 1024) - { - KSycoca::flagError(); - return; - } - for(TQ_UINT32 i = 0; i < count; i++) - { - TQString str; - read(s, str); - list.append( str ); - if (s.atEnd()) - { - KSycoca::flagError(); - return; - } - } -} - -void KSycoca::virtual_hook( int id, void* data ) -{ DCOPObject::virtual_hook( id, data ); } - -void KSycocaEntry::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } - -#include "ksycoca.moc" diff --git a/tdecore/ksycoca.h b/tdecore/ksycoca.h deleted file mode 100644 index adf9d2aa7..000000000 --- a/tdecore/ksycoca.h +++ /dev/null @@ -1,187 +0,0 @@ -/* This file is part of the KDE libraries - * Copyright (C) 1999 Waldo Bastian - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License version 2 as published by the Free Software Foundation; - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - **/ - -#ifndef __ksycoca_h__ -#define __ksycoca_h__ - -#include -#include -#include -#include "ksycocatype.h" -#include - -class TQDataStream; -class KSycocaPrivate; -class KSycocaFactory; -class KSycocaFactoryList; - -/* - * Sycoca file version number. - * If the existing file is outdated, it will not get read - * but instead we'll ask kded to regenerate a new one... -*/ -#define KSYCOCA_VERSION 94 - -/** - * @internal - * Read-only SYstem COnfiguration CAche - */ -class TDECORE_EXPORT KSycoca : public TQObject, public DCOPObject -{ - Q_OBJECT - K_DCOP - -protected: - /** - * @internal - * Building database - */ - KSycoca( bool /* buildDatabase */ ); - -public: - - /** - * Read-only database - */ - KSycoca(); - - /** - * Get or create the only instance of KSycoca (read-only) - */ - static KSycoca *self(); - - virtual ~KSycoca(); - - static int version(); - - /** - * @internal - called by factories in read-only mode - * This is how factories get a stream to an entry - */ - TQDataStream *findEntry(int offset, KSycocaType &type); - /** - * @internal - called by factories in read-only mode - */ - TQDataStream *findFactory( KSycocaFactoryId id); - /** - * @internal - returns kfsstnd stored inside database - */ - TQString kfsstnd_prefixes(); - /** - * @internal - returns language stored inside database - */ - TQString language(); - - /** - * @internal - returns timestamp of database - * - * The database contains all changes made _before_ this time and - * _might_ contain changes made after that. - */ - TQ_UINT32 timeStamp(); - - /** - * @internal - returns update signature of database - * - * Signature that keeps track of changes to - * $TDEDIR/share/services/update_ksycoca - * - * Touching this file causes the database to be recreated - * from scratch. - */ - TQ_UINT32 updateSignature(); - - /** - * @internal - returns all directories with information - * stored inside sycoca. - */ - TQStringList allResourceDirs(); - - /** - * @internal - add a factory - */ - void addFactory( KSycocaFactory * ); - - /** - * @internal - * @return true if building (i.e. if a KBuildSycoca); - */ - virtual bool isBuilding() { return false; } - - /** - * @internal - disables launching of kbuildsycoca - */ - void disableAutoRebuild(); - - /** - * Determine relative path for a .desktop file from a full path and a resource name - */ - static TQString determineRelativePath( const TQString & _fullpath, const char *_resource ); - - /** - * When you receive a "databaseChanged" signal, you can query here if - * a change has occurred in a specific resource type. - * @see KStandardDirs for the various resource types. - */ - static bool isChanged(const char *type); - - /** - * A read error occurs. - */ - static void flagError(); - - /** - * Returns read error status and clears flag. - */ - static bool readError(); - -k_dcop: - /** - * internal function for receiving kded/kbuildsycoca's signal, when the sycoca file changes - */ - void notifyDatabaseChanged(const TQStringList &); - -signals: - /** - * Connect to this to get notified when the database changes - * (Usually apps showing icons do a 'refresh' to take into account the new mimetypes) - */ - void databaseChanged(); - -protected: - bool checkVersion(bool abortOnError=true); - bool openDatabase(bool openDummyIfNotFound=true); - void closeDatabase(); - KSycocaFactoryList *m_lstFactories; - TQDataStream *m_str; - TQByteArray *m_barray; - bool bNoDatabase; - size_t m_sycoca_size; - const char *m_sycoca_mmap; - TQ_UINT32 m_timeStamp; - -public: - static KSycoca *_self; // Internal use only. - -protected: - virtual void virtual_hook( int id, void* data ); -private: - KSycocaPrivate *d; -}; - -#endif diff --git a/tdecore/ksycocadict.cpp b/tdecore/ksycocadict.cpp deleted file mode 100644 index d8dcf3a24..000000000 --- a/tdecore/ksycocadict.cpp +++ /dev/null @@ -1,454 +0,0 @@ -/* This file is part of the KDE libraries - * Copyright (C) 1999 Waldo Bastian - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License version 2 as published by the Free Software Foundation; - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - **/ - -#include "ksycocadict.h" -#include "ksycocaentry.h" -#include "ksycoca.h" - -#include -#include -#include -#include - -namespace -{ -struct string_entry { - string_entry(TQString _key, KSycocaEntry *_payload) - { keyStr = _key; key = keyStr.unicode(); length = keyStr.length(); payload = _payload; hash = 0; } - uint hash; - int length; - const TQChar *key; - TQString keyStr; - KSycocaEntry *payload; -}; -} - -template class TQPtrList; - -class KSycocaDictStringList : public TQPtrList -{ -public: - KSycocaDictStringList(); -}; - -KSycocaDictStringList::KSycocaDictStringList() -{ - setAutoDelete(true); -} - -KSycocaDict::KSycocaDict() - : d(0), mStr(0), mOffset(0) -{ -} - -KSycocaDict::KSycocaDict(TQDataStream *str, int offset) - : d(0), mStr(str), mOffset(offset) -{ - TQ_UINT32 test1, test2; - str->device()->at(offset); - (*str) >> test1 >> test2; - if ((test1 > 0x000fffff) || (test2 > 1024)) - { - KSycoca::flagError(); - mHashTableSize = 0; - mOffset = 0; - return; - } - - str->device()->at(offset); - (*str) >> mHashTableSize; - (*str) >> mHashList; - mOffset = str->device()->at(); // Start of hashtable -} - -KSycocaDict::~KSycocaDict() -{ - delete d; -} - -void -KSycocaDict::add(const TQString &key, KSycocaEntry *payload) -{ - if (key.isEmpty()) return; // Not allowed (should never happen) - if (!payload) return; // Not allowed! - if (!d) - { - d = new KSycocaDictStringList(); - } - - string_entry *entry= new string_entry(key, payload); - d->append(entry); -} - -void -KSycocaDict::remove(const TQString &key) -{ - if (d) - { - for(string_entry *entry=d->first(); entry; entry = d->next()) - { - if (entry->keyStr == key) - { - d->remove(); - break; - } - } - } -} - -int -KSycocaDict::find_string(const TQString &key ) -{ - //kdDebug(7011) << TQString("KSycocaDict::find_string(%1)").arg(key) << endl; - - if (!mStr || !mOffset) - { - kdError(7011) << "No database available!" << endl; - return 0; - } - - if (mHashTableSize == 0) - return 0; // Unlikely to find anything :-] - - // Read hash-table data - uint hash = hashKey(key) % mHashTableSize; - //kdDebug(7011) << TQString("hash is %1").arg(hash) << endl; - - uint off = mOffset+sizeof(TQ_INT32)*hash; - //kdDebug(7011) << TQString("off is %1").arg(off,8,16) << endl; - mStr->device()->at( off ); - - TQ_INT32 offset; - (*mStr) >> offset; - - //kdDebug(7011) << TQString("offset is %1").arg(offset,8,16) << endl; - if (offset == 0) - return 0; - - if (offset > 0) - return offset; // Positive ID - - // Lookup duplicate list. - offset = -offset; - - mStr->device()->at(offset); - //kdDebug(7011) << TQString("Looking up duplicate list at %1").arg(offset,8,16) << endl; - - while(true) - { - (*mStr) >> offset; - if (offset == 0) break; - TQString dupkey; - (*mStr) >> dupkey; - //kdDebug(7011) << TQString(">> %1 %2").arg(offset,8,16).arg(dupkey) << endl; - if (dupkey == key) return offset; - } - //kdWarning(7011) << "Not found!" << endl; - - return 0; -} - -uint -KSycocaDict::count() -{ - if (!d) return 0; - - return d->count(); -} - -void -KSycocaDict::clear() -{ - delete d; - d = 0; -} - -uint -KSycocaDict::hashKey( const TQString &key) -{ - int l = key.length(); - register uint h = 0; - - for(uint i = 0; i < mHashList.count(); i++) - { - int pos = mHashList[i]; - if (pos < 0) - { - pos = -pos-1; - if (pos < l) - h = ((h * 13) + (key[l-pos].cell() % 29)) & 0x3ffffff; - } - else - { - pos = pos-1; - if (pos < l) - h = ((h * 13) + (key[pos].cell() % 29)) & 0x3ffffff; - } - } - return h; -} - -// -// Calculate the diversity of the strings at position 'pos' -static int -calcDiversity(KSycocaDictStringList *d, int pos, int sz) -{ - if (pos == 0) return 0; - bool *matrix = (bool *) calloc(sz, sizeof(bool)); - uint usz = sz; - - if (pos < 0) - { - pos = -pos-1; - for(string_entry *entry=d->first(); entry; entry = d->next()) - { - register int l = entry->length; - if (pos < l && pos != 0) - { - register uint hash = ((entry->hash * 13) + (entry->key[l-pos].cell() % 29)) & 0x3ffffff; - matrix[ hash % usz ] = true; - } - } - } - else - { - pos = pos-1; - for(string_entry *entry=d->first(); entry; entry = d->next()) - { - if (pos < entry->length) - { - register uint hash = ((entry->hash * 13) + (entry->key[pos].cell() % 29)) & 0x3ffffff; - matrix[ hash % usz ] = true; - } - } - } - int diversity = 0; - for(int i=0;i< sz;i++) - if (matrix[i]) diversity++; - - free((void *) matrix); - - return diversity; -} - -// -// Add the diversity of the strings at position 'pos' -static void -addDiversity(KSycocaDictStringList *d, int pos) -{ - if (pos == 0) return; - if (pos < 0) - { - pos = -pos-1; - for(string_entry *entry=d->first(); entry; entry = d->next()) - { - register int l = entry->length; - if (pos < l) - entry->hash = ((entry->hash * 13) + (entry->key[l-pos].cell() % 29)) & 0x3fffffff; - } - } - else - { - pos = pos - 1; - for(string_entry *entry=d->first(); entry; entry = d->next()) - { - if (pos < entry->length) - entry->hash = ((entry->hash * 13) + (entry->key[pos].cell() % 29)) & 0x3fffffff; - } - } -} - - -void -KSycocaDict::save(TQDataStream &str) -{ - if (count() == 0) - { - mHashTableSize = 0; - mHashList.clear(); - str << mHashTableSize; - str << mHashList; - return; - } - - mOffset = str.device()->at(); - - //kdDebug(7011) << TQString("KSycocaDict: %1 entries.").arg(count()) << endl; - - //kdDebug(7011) << "Calculating hash keys.." << endl; - - int maxLength = 0; - //kdDebug(7011) << "Finding maximum string length" << endl; - for(string_entry *entry=d->first(); entry; entry = d->next()) - { - entry->hash = 0; - if (entry->length > maxLength) - maxLength = entry->length; - } - - //kdDebug(7011) << TQString("Max string length = %1").arg(maxLength) << endl; - - // use "almost prime" number for sz (to calculate diversity) and later - // for the table size of big tables - // int sz = d->count()*5-1; - register unsigned int sz = count()*4 + 1; - while(!(((sz % 3) && (sz % 5) && (sz % 7) && (sz % 11) && (sz % 13)))) sz+=2; - - int maxDiv = 0; - int maxPos = 0; - int lastDiv = 0; - - mHashList.clear(); - - // try to limit diversity scan by "predicting" positions - // with high diversity - int *oldvec=new int[maxLength*2+1]; - for (int i=0; i<(maxLength*2+1); i++) oldvec[i]=0; - int mindiv=0; - - while(true) - { - int divsum=0,divnum=0; - - maxDiv = 0; - maxPos = 0; - for(int pos=-maxLength; pos <= maxLength; pos++) - { - // cut off - if (oldvec[pos+maxLength] maxDiv) - { - maxDiv = diversity; - maxPos = pos; - } - oldvec[pos+maxLength]=diversity; - divsum+=diversity; divnum++; - } - // arbitrary cut-off value 3/4 of average seems to work - if (divnum) - mindiv=(3*divsum)/(4*divnum); - - if (maxDiv <= lastDiv) - break; - // tqWarning("Max Div = %d at pos %d", maxDiv, maxPos); - lastDiv = maxDiv; - addDiversity(d, maxPos); - mHashList.append(maxPos); - } - - delete [] oldvec; - - for(string_entry *entry=d->first(); entry; entry = d->next()) - { - entry->hash = hashKey(entry->keyStr); - } -// fprintf(stderr, "Calculating minimum table size..\n"); - - mHashTableSize = sz; - - struct hashtable_entry { - string_entry *entry; - TQPtrList *duplicates; - int duplicate_offset; - }; - - hashtable_entry *hashTable = new hashtable_entry[ sz ]; - - //kdDebug(7011) << "Clearing hashtable..." << endl; - for (unsigned int i=0; i < sz; i++) - { - hashTable[i].entry = 0; - hashTable[i].duplicates = 0; - } - - //kdDebug(7011) << "Filling hashtable..." << endl; - for(string_entry *entry=d->first(); entry; entry = d->next()) - { - int hash = entry->hash % sz; - if (!hashTable[hash].entry) - { // First entry - hashTable[hash].entry = entry; - } - else - { - if (!hashTable[hash].duplicates) - { // Second entry, build duplicate list. - hashTable[hash].duplicates = new TQPtrList(); - hashTable[hash].duplicates->append(hashTable[hash].entry); - hashTable[hash].duplicate_offset = 0; - } - hashTable[hash].duplicates->append(entry); - } - } - - str << mHashTableSize; - str << mHashList; - - mOffset = str.device()->at(); // mOffset points to start of hashTable - //kdDebug(7011) << TQString("Start of Hash Table, offset = %1").arg(mOffset,8,16) << endl; - - for(int pass = 1; pass <= 2; pass++) - { - str.device()->at(mOffset); - //kdDebug(7011) << TQString("Writing hash table (pass #%1)").arg(pass) << endl; - for(uint i=0; i < mHashTableSize; i++) - { - TQ_INT32 tmpid; - if (!hashTable[i].entry) - tmpid = (TQ_INT32) 0; - else if (!hashTable[i].duplicates) - tmpid = (TQ_INT32) hashTable[i].entry->payload->offset(); // Positive ID - else - tmpid = (TQ_INT32) -hashTable[i].duplicate_offset; // Negative ID - str << tmpid; - //kdDebug(7011) << TQString("Hash table : %1").arg(tmpid,8,16) << endl; - } - //kdDebug(7011) << TQString("End of Hash Table, offset = %1").arg(str.device()->at(),8,16) << endl; - - //kdDebug(7011) << TQString("Writing duplicate lists (pass #%1)").arg(pass) << endl; - for(uint i=0; i < mHashTableSize; i++) - { - if (hashTable[i].duplicates) - { - TQPtrList *dups = hashTable[i].duplicates; - hashTable[i].duplicate_offset = str.device()->at(); - - /*kdDebug(7011) << TQString("Duplicate lists: Offset = %1 list_size = %2") .arg(hashTable[i].duplicate_offset,8,16).arg(dups->count()) << endl; -*/ - for(string_entry *dup = dups->first(); dup; dup=dups->next()) - { - str << (TQ_INT32) dup->payload->offset(); // Positive ID - str << dup->keyStr; // Key (TQString) - } - str << (TQ_INT32) 0; // End of list marker (0) - } - } - //kdDebug(7011) << TQString("End of Dict, offset = %1").arg(str.device()->at(),8,16) << endl; - } - - //kdDebug(7011) << "Cleaning up hash table." << endl; - for(uint i=0; i < mHashTableSize; i++) - { - delete hashTable[i].duplicates; - } - delete [] hashTable; -} - diff --git a/tdecore/ksycocadict.h b/tdecore/ksycocadict.h deleted file mode 100644 index 79f1432e8..000000000 --- a/tdecore/ksycocadict.h +++ /dev/null @@ -1,123 +0,0 @@ -/* This file is part of the KDE libraries - * Copyright (C) 1999 Waldo Bastian - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License version 2 as published by the Free Software Foundation; - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - **/ - -#ifndef __ksycocadict_h__ -#define __ksycocadict_h__ - -#include -#include -#include -#include "tdelibs_export.h" - -class KSycocaEntry; -class KSycocaDictStringList; - -/** - * @internal - * Hash table implementation for the sycoca database file - */ -class TDECORE_EXPORT KSycocaDict -{ -public: - /** - * Create an empty dict, for building the database - */ - KSycocaDict(); - /** - * Create a dict from an existing database - */ - KSycocaDict(TQDataStream *str, int offset); - - ~KSycocaDict(); - - /** - * Adds a 'payload' to the dictionary with key 'key'. - * - * 'payload' should have a valid offset by the time - * the dictionary gets saved. - **/ - void add(const TQString &key, KSycocaEntry *payload); - - /** - * Removes the 'payload' from the dictionary with key 'key'. - * - * Not very fast, use with care O(N) - **/ - void remove(const TQString &key); - - /** - * Looks up an entry identified by 'key'. - * - * If 0 is returned, no matching entry exists. - * Otherwise, the offset of the entry is returned. - * - * NOTE: It is not guaranteed that this entry is - * indeed the one you were looking for. - * After loading the entry you should check that it - * indeed matches the search key. If it doesn't - * then no matching entry exists. - */ - int find_string(const TQString &key ); - - /** - * The number of entries in the dictionary. - * - * Only valid when building the database. - */ - uint count(); - - /** - * Reset the dictionary. - * - * Only valid when building the database. - */ - void clear(); - - /** - * Save the dictionary to the stream - * A reasonable fast hash algorithm will be created. - * - * Typically this will find 90% of the entries directly. - * Average hash table size: nrOfItems * 20 bytes. - * Average duplicate list size: nrOfItms * avgKeyLength / 5. - * - * Unknown keys have an average 20% chance to give a false hit. - * (That's why your program should check the result) - * - * Example: - * Assume 1000 items with an average key length of 60 bytes. - * - * Approx. 900 items will hash directly to the right entry. - * Approx. 100 items require a lookup in the duplicate list. - * - * The hash table size will be approx. 20Kb. - * The duplicate list size will be approx. 12Kb. - **/ - void save(TQDataStream &str); - -protected: - TQ_UINT32 hashKey( const TQString &); -private: - KSycocaDictStringList *d; - TQDataStream *mStr; - TQ_INT32 mOffset; - TQ_UINT32 mHashTableSize; - TQValueList mHashList; -}; - -#endif diff --git a/tdecore/ksycocaentry.h b/tdecore/ksycocaentry.h deleted file mode 100644 index a3071ec5a..000000000 --- a/tdecore/ksycocaentry.h +++ /dev/null @@ -1,123 +0,0 @@ -/* This file is part of the KDE libraries - * Copyright (C) 1999 Waldo Bastian - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License version 2 as published by the Free Software Foundation; - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - **/ - -#ifndef __ksycocaentry_h__ -#define __ksycocaentry_h__ - -#include "ksycocatype.h" - -#include -#include -class TQDataStream; - -/** - * Base class for all Sycoca entries. - * - * You can't create an instance of KSycocaEntry, but it provides - * the common functionality for servicetypes and services. - * - * @internal - * @see http://developer.kde.org/documentation/library/kdeqt/trinityarch/ksycoca.html - */ -class TDECORE_EXPORT KSycocaEntry : public KShared -{ - -public: - virtual bool isType(KSycocaType t) const { return (t == KST_KSycocaEntry); } - virtual KSycocaType sycocaType() const { return KST_KSycocaEntry; } - -public: - typedef KSharedPtr Ptr; - typedef TQValueList List; -public: // KDoc seems to barf on those typedefs and generates no docs after them - /** - * Default constructor - */ - KSycocaEntry(const TQString &path) : mOffset(0), m_bDeleted(false), mPath(path) { } - - /** - * Safe demarshalling functions. - */ - static void read( TQDataStream &s, TQString &str ); - static void read( TQDataStream &s, TQStringList &list ); - - /** - * @internal - * Restores itself from a stream. - */ - KSycocaEntry( TQDataStream &_str, int offset ) : - mOffset( offset ), m_bDeleted(false) - { - read(_str, mPath); - } - - /** - * @return the name of this entry - */ - virtual TQString name() const = 0; - - /** - * @return the path of this entry - * The path can be absolute or relative. - * The corresponding factory should know relative to what. - */ - TQString entryPath() const { return mPath; } - - /** - * @return true if valid - */ - virtual bool isValid() const = 0; - - /** - * @return true if deleted - */ - virtual bool isDeleted() const { return m_bDeleted; } - - /** - * @internal - * @return the position of the entry in the sycoca file - */ - int offset() { return mOffset; } - - /** - * @internal - * Save ourselves to the database. Don't forget to call the parent class - * first if you override this function. - */ - virtual void save(TQDataStream &s) - { - mOffset = s.device()->at(); // store position in member variable - s << (TQ_INT32) sycocaType() << mPath; - } - - /** - * @internal - * Load ourselves from the database. Don't call the parent class! - */ - virtual void load(TQDataStream &) = 0; - -private: - int mOffset; -protected: - bool m_bDeleted; - TQString mPath; -protected: - virtual void virtual_hook( int id, void* data ); -}; - -#endif diff --git a/tdecore/ksycocafactory.cpp b/tdecore/ksycocafactory.cpp deleted file mode 100644 index c224ebe79..000000000 --- a/tdecore/ksycocafactory.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/* This file is part of the KDE libraries - * Copyright (C) 1999 David Faure - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License version 2 as published by the Free Software Foundation; - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - **/ - -#include "ksycoca.h" -#include "ksycocatype.h" -#include "ksycocafactory.h" -#include "ksycocaentry.h" -#include "ksycocadict.h" -#include -#include -#include - -template class TQDict; -template class TQDict >; - -KSycocaFactory::KSycocaFactory(KSycocaFactoryId factory_id) - : m_resourceList(0), m_entryDict(0), m_sycocaDict(0) -{ - if (!KSycoca::self()->isBuilding()) // read-only database ? - { - m_str = KSycoca::self()->findFactory( factory_id ); - // can't call factoryId() here since the constructor can't call inherited methods - if (m_str) // Can be 0 in case of errors - { - // Read position of index tables.... - TQ_INT32 i; - (*m_str) >> i; - m_sycocaDictOffset = i; - (*m_str) >> i; - m_beginEntryOffset = i; - (*m_str) >> i; - m_endEntryOffset = i; - - int saveOffset = m_str->device()->at(); - // Init index tables - m_sycocaDict = new KSycocaDict(m_str, m_sycocaDictOffset); - saveOffset = m_str->device()->at(saveOffset); - } - } - else - { - // Build new database! - m_str = 0; - m_resourceList = 0; - m_entryDict = new KSycocaEntryDict(977); - m_entryDict->setAutoDelete(true); - m_sycocaDict = new KSycocaDict(); - m_beginEntryOffset = 0; - m_endEntryOffset = 0; - - // m_resourceList will be filled in by inherited constructors - } - KSycoca::self()->addFactory(this); -} - -KSycocaFactory::~KSycocaFactory() -{ - delete m_entryDict; - delete m_sycocaDict; -} - -void -KSycocaFactory::saveHeader(TQDataStream &str) -{ - // Write header - str.device()->at(mOffset); - str << (TQ_INT32) m_sycocaDictOffset; - str << (TQ_INT32) m_beginEntryOffset; - str << (TQ_INT32) m_endEntryOffset; -} - -void -KSycocaFactory::save(TQDataStream &str) -{ - if (!m_entryDict) return; // Error! Function should only be called when - // building database - if (!m_sycocaDict) return; // Error! - - mOffset = str.device()->at(); // store position in member variable - m_sycocaDictOffset = 0; - - // Write header (pass #1) - saveHeader(str); - - m_beginEntryOffset = str.device()->at(); - - // Write all entries. - int entryCount = 0; - for(TQDictIterator it ( *m_entryDict ); - it.current(); - ++it) - { - KSycocaEntry *entry = (*it.current()); - entry->save(str); - entryCount++; - } - - m_endEntryOffset = str.device()->at(); - - // Write indices... - // Linear index - str << (TQ_INT32) entryCount; - for(TQDictIterator it ( *m_entryDict ); - it.current(); - ++it) - { - KSycocaEntry *entry = (*it.current()); - str << (TQ_INT32) entry->offset(); - } - - // Dictionary index - m_sycocaDictOffset = str.device()->at(); - m_sycocaDict->save(str); - - int endOfFactoryData = str.device()->at(); - - // Update header (pass #2) - saveHeader(str); - - // Seek to end. - str.device()->at(endOfFactoryData); -} - -void -KSycocaFactory::addEntry(KSycocaEntry *newEntry, const char *) -{ - if (!m_entryDict) return; // Error! Function should only be called when - // building database - - if (!m_sycocaDict) return; // Error! - - TQString name = newEntry->name(); - m_entryDict->insert( name, new KSycocaEntry::Ptr(newEntry) ); - m_sycocaDict->add( name, newEntry ); -} - -void -KSycocaFactory::removeEntry(KSycocaEntry *newEntry) -{ - if (!m_entryDict) return; // Error! Function should only be called when - // building database - - if (!m_sycocaDict) return; // Error! - - TQString name = newEntry->name(); - m_entryDict->remove( name ); - m_sycocaDict->remove( name ); -} - -KSycocaEntry::List KSycocaFactory::allEntries() -{ - KSycocaEntry::List list; - if (!m_str) return list; - - // Assume we're NOT building a database - - m_str->device()->at(m_endEntryOffset); - TQ_INT32 entryCount; - (*m_str) >> entryCount; - - if (entryCount > 8192) - { - KSycoca::flagError(); - return list; - } - - TQ_INT32 *offsetList = new TQ_INT32[entryCount]; - for(int i = 0; i < entryCount; i++) - { - (*m_str) >> offsetList[i]; - } - - for(int i = 0; i < entryCount; i++) - { - KSycocaEntry *newEntry = createEntry(offsetList[i]); - if (newEntry) - { - list.append( KSycocaEntry::Ptr( newEntry ) ); - } - } - delete [] offsetList; - return list; -} - -void KSycocaFactory::virtual_hook( int /*id*/, void* /*data*/) -{ /*BASE::virtual_hook( id, data );*/ } - diff --git a/tdecore/ksycocafactory.h b/tdecore/ksycocafactory.h deleted file mode 100644 index 100047834..000000000 --- a/tdecore/ksycocafactory.h +++ /dev/null @@ -1,143 +0,0 @@ -/* This file is part of the KDE libraries - * Copyright (C) 1999 Waldo Bastian - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License version 2 as published by the Free Software Foundation; - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - **/ - -#ifndef __ksycocafactory_h__ -#define __ksycocafactory_h__ - -#include "ksycocatype.h" -#include "ksycocaentry.h" - -#include -#include -class KSycoca; -class TQStringList; -class TQString; -class KSycocaDict; -class KSycocaResourceList; - -typedef TQDict KSycocaEntryDict; - -/** - * @internal - * Base class for sycoca factories - */ -class TDECORE_EXPORT KSycocaFactory -{ -public: - virtual KSycocaFactoryId factoryId() const = 0; - -protected: // virtual class - /** - * Create a factory which can be used to lookup from/create a database - * (depending on KSycoca::isBuilding()) - */ - KSycocaFactory( KSycocaFactoryId factory_id ); - -public: - virtual ~KSycocaFactory(); - - /** - * @return the position of the factory in the sycoca file - */ - int offset() { return mOffset; } - - /** - * @return the dict, for special use by KBuildSycoca - */ - KSycocaEntryDict * entryDict() { return m_entryDict; } - - /** - * Construct an entry from a config file. - * To be implemented in the real factories. - */ - virtual KSycocaEntry *createEntry(const TQString &file, const char *resource) = 0; - - /** - * Add an entry - */ - virtual void addEntry(KSycocaEntry *newEntry, const char *resource); - - /** - * Remove an entry - * Not very fast, use with care. O(N) - */ - void removeEntry(KSycocaEntry *newEntry); - - /** - * Read an entry from the database - */ - virtual KSycocaEntry *createEntry(int offset)=0; - - /** - * Get a list of all entries from the database. - */ - KSycocaEntry::List allEntries(); - - /** - * Saves all entries it maintains as well as index files - * for these entries to the stream 'str'. - * - * Also sets mOffset to the starting position. - * - * The stream is positioned at the end of the last index. - * - * Don't forget to call the parent first when you override - * this function. - */ - virtual void save(TQDataStream &str); - - /** - * Writes out a header to the stream 'str'. - * The baseclass positions the stream correctly. - * - * Don't forget to call the parent first when you override - * this function. - */ - virtual void saveHeader(TQDataStream &str); - - /** - * @return the resources for which this factory is responsible. - */ - virtual const KSycocaResourceList * resourceList() const { return m_resourceList; } - -private: - int mOffset; - -protected: - int m_sycocaDictOffset; - int m_beginEntryOffset; - int m_endEntryOffset; - TQDataStream *m_str; - - KSycocaResourceList *m_resourceList; - KSycocaEntryDict *m_entryDict; - KSycocaDict *m_sycocaDict; -protected: - virtual void virtual_hook( int id, void* data ); -}; - -/** This, instead of a typedef, allows to declare "class ..." in header files - * @internal - */ -class TDECORE_EXPORT KSycocaFactoryList : public TQPtrList -{ -public: - KSycocaFactoryList() { } -}; - -#endif diff --git a/tdecore/ksycocatype.h b/tdecore/ksycocatype.h deleted file mode 100644 index 889c3be6d..000000000 --- a/tdecore/ksycocatype.h +++ /dev/null @@ -1,64 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 1998, 1999 Torben Weis - Waldo Bastian - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef __ksycocatype_h__ -#define __ksycocatype_h__ - -/** - * \relates KSycocaEntry - * A KSycocaType is a code (out of the KSycocaType enum) assigned to each - * class type derived from KSycocaEntry . - * To use it, call the macro K_SYCOCATYPE( your_typecode, parent_class ) - * at the top of your class definition. - */ -enum KSycocaType { KST_KSycocaEntry = 0, KST_KService = 1, KST_KServiceType = 2, KST_KMimeType = 3, - KST_KFolderType = 4, KST_KDEDesktopMimeType = 5, KST_KExecMimeType = 6, - KST_KServiceGroup = 7, KST_KImageIOFormat = 8, KST_KProtocolInfo = 9, - KST_KServiceSeparator = 10, - KST_KCustom = 1000 }; - -#define K_SYCOCATYPE( type, baseclass ) \ -public: \ - virtual bool isType(KSycocaType t) const { if (t == type) return true; return baseclass::isType(t);} \ - virtual KSycocaType sycocaType() const { return type; } \ -private: - -/** - * \relates KSycocaFactory - * A KSycocaFactoryId is a code (out of the KSycocaFactoryId enum) - * assigned to each class type derived from KSycocaFactory. - * To use it, call the macro K_SYCOCAFACTORY( your_factory_id ) - * at the top of your class definition. - */ -enum KSycocaFactoryId { KST_KServiceFactory = 1, - KST_KServiceTypeFactory = 2, - KST_KServiceGroupFactory = 3, - KST_KImageIO = 4, - KST_KProtocolInfoFactory = 5, - KST_CTimeInfo = 100 }; - -#define K_SYCOCAFACTORY( factory_id ) \ -public: \ - virtual KSycocaFactoryId factoryId() const { return factory_id; } \ -private: - - - -#endif diff --git a/tdecore/network/CMakeLists.txt b/tdecore/network/CMakeLists.txt index addc3633b..5c213a752 100644 --- a/tdecore/network/CMakeLists.txt +++ b/tdecore/network/CMakeLists.txt @@ -24,7 +24,7 @@ install( FILES kresolver.h kreverseresolver.h tdesocketaddress.h tdesocketbase.h tdesocketdevice.h kclientsocketbase.h kstreamsocket.h kserversocket.h kdatagramsocket.h - kmulticastsocketdevice.h kmulticastsocket.h + tdemulticastsocketdevice.h tdemulticastsocket.h knetworkinterface.h khttpproxysocketdevice.h ksockssocketdevice.h kbufferedsocket.h kiobuffer.h DESTINATION ${INCLUDE_INSTALL_DIR} ) diff --git a/tdecore/network/Makefile.am b/tdecore/network/Makefile.am index 768180d1b..793b6d96d 100644 --- a/tdecore/network/Makefile.am +++ b/tdecore/network/Makefile.am @@ -38,8 +38,8 @@ include_HEADERS = kresolver.h \ kstreamsocket.h \ kserversocket.h \ kdatagramsocket.h \ - kmulticastsocketdevice.h \ - kmulticastsocket.h \ + tdemulticastsocketdevice.h \ + tdemulticastsocket.h \ knetworkinterface.h \ khttpproxysocketdevice.h \ ksockssocketdevice.h \ diff --git a/tdecore/network/kmulticastsocket.h b/tdecore/network/kmulticastsocket.h deleted file mode 100644 index 8fe413283..000000000 --- a/tdecore/network/kmulticastsocket.h +++ /dev/null @@ -1,113 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003 Thiago Macieira - * - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef KMULTICASTSOCKET_H -#define KMULTICASTSOCKET_H - -#include "kdatagramsocket.h" -#include "kmulticastsocketdevice.h" - -namespace KNetwork { - -class KMulticastSocketPrivate; -/** - * @class KMulticastSocket kmulticastsocket.h kmulticastsocket.h - * @brief A multicast-capable datagram socket class - * - * This class derives from @ref KDatagramSocket adding methods to it to - * allow better control over the multicast functionality. In special, - * the join and leave group functions are added. - * - * Other more low-level options on multicast sockets can be accessed - * directly with the @ref KMulticastSocketImpl class returned by - * @ref multicastSocketDevice. - * - * @author Thiago Macieira - */ -class TDECORE_EXPORT KMulticastSocket: public KDatagramSocket -{ - // Q_add-it-here_OBJECT -public: - /** - * Constructor. - */ - KMulticastSocket(TQObject* parent = 0L, const char *name = 0L); - - /** - * Destructor. - */ - ~KMulticastSocket(); - - /** - * Returns the multicast socket device in use by this object. - * - * @note The returned object can be null. - */ - KMulticastSocketImpl* multicastSocketDevice(); - - /** - * @overload - */ - const KMulticastSocketImpl* multicastSocketDevice() const; - - /** - * Joins a multicast group. The group to be joined is identified by the - * @p group parameter. - * - * @param group the multicast group to join - * @returns true on success - */ - virtual bool joinGroup(const TDESocketAddress& group); - - /** - * @overload - * Joins a multicast group. This function also specifies the network interface - * to be used. - */ - virtual bool joinGroup(const TDESocketAddress& group, - const KNetworkInterface& iface); - - /** - * Leaves a multicast group. The group being left is given by its address in the - * @p group parameter. - * - * @param group the group to leave - * @returns true on successful leaving the group - */ - virtual bool leaveGroup(const TDESocketAddress& group); - - /** - * @overload - * Leaves a multicast group. - */ - virtual bool leaveGroup(const TDESocketAddress& group, - const KNetworkInterface& iface); - -private: - KMulticastSocketPrivate *d; -}; - -} // namespace KNetwork - -#endif diff --git a/tdecore/network/kmulticastsocketdevice.h b/tdecore/network/kmulticastsocketdevice.h deleted file mode 100644 index a24ba326a..000000000 --- a/tdecore/network/kmulticastsocketdevice.h +++ /dev/null @@ -1,151 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003 Thiago Macieira - * - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef KMULTICASTSOCKETDEVICE_H -#define KMULTICASTSOCKETDEVICE_H - -#include "tdesocketdevice.h" -#include "knetworkinterface.h" -#include "tdesocketaddress.h" - -namespace KNetwork { - -class KMulticastSocketImplPrivate; - -/** - * @class KMulticastSocketImpl kmulticastsocketdevice.h kmulticastsocketdevice.h - * @brief The low-level backend for multicasting sockets. - * - * This class is an interface providing methods for handling multicast - * operations. - * - * @author Thiago Macieira - */ -class KMulticastSocketImpl: public TDESocketDevice -{ -public: - /** - * Constructor. - */ - KMulticastSocketImpl(const TDESocketBase* = 0L); - - /** - * Destructor - */ - virtual ~KMulticastSocketImpl(); - - /** - * Sets our capabilities. - */ - virtual int capabilities() const; - - /** - * Overrides the socket creation. - */ - virtual bool create(int family, int type, int protocol); - - /** - * Overrides connection. Multicast sockets may not connect. - */ - virtual bool connect(const KResolverEntry& address); - - /** - * Retrieves the time-to-live/hop count value on multicast packets being sent. - */ - virtual int timeToLive() const; - - /** - * Sets the time-to-live/hop count for outgoing multicast packets. - * - * @param ttl the hop count, from 0 to 255 - * @returns true if setting the value was successful. - */ - virtual bool setTimeToLive(int ttl); - - /** - * Retrieves the flag indicating if sent packets will be echoed back - * to sender. - */ - virtual bool multicastLoop() const; - - /** - * Sets the flag indicating the loopback of packets to the sender. - * - * @param enable if true, will echo back - * @returns true if setting the value was successful. - */ - virtual bool setMulticastLoop(bool enable); - - /** - * Retrieves the network interface this socket is associated to. - */ - virtual KNetworkInterface networkInterface(); - - /** - * Sets the network interface on which this socket should work. - * - * @param iface the interface to associate with - * @return true if setting the value was successful. - */ - virtual bool setNetworkInterface(const KNetworkInterface& iface); - - /** - * Joins a multicast group. The group to be joined is identified by the - * @p group parameter. - * - * @param group the multicast group to join - * @returns true on success - */ - virtual bool joinGroup(const TDESocketAddress& group); - - /** - * @overload - * Joins a multicast group. This function also specifies the network interface - * to be used. - */ - virtual bool joinGroup(const TDESocketAddress& group, - const KNetworkInterface& iface); - - /** - * Leaves a multicast group. The group being left is given by its address in the - * @p group parameter. - * - * @param group the group to leave - * @returns true on successful leaving the group - */ - virtual bool leaveGroup(const TDESocketAddress& group); - - /** - * @overload - * Leaves a multicast group. - */ - virtual bool leaveGroup(const TDESocketAddress& group, - const KNetworkInterface& iface); -private: - KMulticastSocketImplPrivate *d; -}; - -} // namespace KNetwork - -#endif diff --git a/tdecore/network/tdemulticastsocket.h b/tdecore/network/tdemulticastsocket.h new file mode 100644 index 000000000..15d3a28ea --- /dev/null +++ b/tdecore/network/tdemulticastsocket.h @@ -0,0 +1,113 @@ +/* -*- C++ -*- + * Copyright (C) 2003 Thiago Macieira + * + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef KMULTICASTSOCKET_H +#define KMULTICASTSOCKET_H + +#include "kdatagramsocket.h" +#include "tdemulticastsocketdevice.h" + +namespace KNetwork { + +class KMulticastSocketPrivate; +/** + * @class KMulticastSocket tdemulticastsocket.h tdemulticastsocket.h + * @brief A multicast-capable datagram socket class + * + * This class derives from @ref KDatagramSocket adding methods to it to + * allow better control over the multicast functionality. In special, + * the join and leave group functions are added. + * + * Other more low-level options on multicast sockets can be accessed + * directly with the @ref KMulticastSocketImpl class returned by + * @ref multicastSocketDevice. + * + * @author Thiago Macieira + */ +class TDECORE_EXPORT KMulticastSocket: public KDatagramSocket +{ + // Q_add-it-here_OBJECT +public: + /** + * Constructor. + */ + KMulticastSocket(TQObject* parent = 0L, const char *name = 0L); + + /** + * Destructor. + */ + ~KMulticastSocket(); + + /** + * Returns the multicast socket device in use by this object. + * + * @note The returned object can be null. + */ + KMulticastSocketImpl* multicastSocketDevice(); + + /** + * @overload + */ + const KMulticastSocketImpl* multicastSocketDevice() const; + + /** + * Joins a multicast group. The group to be joined is identified by the + * @p group parameter. + * + * @param group the multicast group to join + * @returns true on success + */ + virtual bool joinGroup(const TDESocketAddress& group); + + /** + * @overload + * Joins a multicast group. This function also specifies the network interface + * to be used. + */ + virtual bool joinGroup(const TDESocketAddress& group, + const KNetworkInterface& iface); + + /** + * Leaves a multicast group. The group being left is given by its address in the + * @p group parameter. + * + * @param group the group to leave + * @returns true on successful leaving the group + */ + virtual bool leaveGroup(const TDESocketAddress& group); + + /** + * @overload + * Leaves a multicast group. + */ + virtual bool leaveGroup(const TDESocketAddress& group, + const KNetworkInterface& iface); + +private: + KMulticastSocketPrivate *d; +}; + +} // namespace KNetwork + +#endif diff --git a/tdecore/network/tdemulticastsocketdevice.h b/tdecore/network/tdemulticastsocketdevice.h new file mode 100644 index 000000000..bddb048a8 --- /dev/null +++ b/tdecore/network/tdemulticastsocketdevice.h @@ -0,0 +1,151 @@ +/* -*- C++ -*- + * Copyright (C) 2003 Thiago Macieira + * + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef KMULTICASTSOCKETDEVICE_H +#define KMULTICASTSOCKETDEVICE_H + +#include "tdesocketdevice.h" +#include "knetworkinterface.h" +#include "tdesocketaddress.h" + +namespace KNetwork { + +class KMulticastSocketImplPrivate; + +/** + * @class KMulticastSocketImpl tdemulticastsocketdevice.h tdemulticastsocketdevice.h + * @brief The low-level backend for multicasting sockets. + * + * This class is an interface providing methods for handling multicast + * operations. + * + * @author Thiago Macieira + */ +class KMulticastSocketImpl: public TDESocketDevice +{ +public: + /** + * Constructor. + */ + KMulticastSocketImpl(const TDESocketBase* = 0L); + + /** + * Destructor + */ + virtual ~KMulticastSocketImpl(); + + /** + * Sets our capabilities. + */ + virtual int capabilities() const; + + /** + * Overrides the socket creation. + */ + virtual bool create(int family, int type, int protocol); + + /** + * Overrides connection. Multicast sockets may not connect. + */ + virtual bool connect(const KResolverEntry& address); + + /** + * Retrieves the time-to-live/hop count value on multicast packets being sent. + */ + virtual int timeToLive() const; + + /** + * Sets the time-to-live/hop count for outgoing multicast packets. + * + * @param ttl the hop count, from 0 to 255 + * @returns true if setting the value was successful. + */ + virtual bool setTimeToLive(int ttl); + + /** + * Retrieves the flag indicating if sent packets will be echoed back + * to sender. + */ + virtual bool multicastLoop() const; + + /** + * Sets the flag indicating the loopback of packets to the sender. + * + * @param enable if true, will echo back + * @returns true if setting the value was successful. + */ + virtual bool setMulticastLoop(bool enable); + + /** + * Retrieves the network interface this socket is associated to. + */ + virtual KNetworkInterface networkInterface(); + + /** + * Sets the network interface on which this socket should work. + * + * @param iface the interface to associate with + * @return true if setting the value was successful. + */ + virtual bool setNetworkInterface(const KNetworkInterface& iface); + + /** + * Joins a multicast group. The group to be joined is identified by the + * @p group parameter. + * + * @param group the multicast group to join + * @returns true on success + */ + virtual bool joinGroup(const TDESocketAddress& group); + + /** + * @overload + * Joins a multicast group. This function also specifies the network interface + * to be used. + */ + virtual bool joinGroup(const TDESocketAddress& group, + const KNetworkInterface& iface); + + /** + * Leaves a multicast group. The group being left is given by its address in the + * @p group parameter. + * + * @param group the group to leave + * @returns true on successful leaving the group + */ + virtual bool leaveGroup(const TDESocketAddress& group); + + /** + * @overload + * Leaves a multicast group. + */ + virtual bool leaveGroup(const TDESocketAddress& group, + const KNetworkInterface& iface); +private: + KMulticastSocketImplPrivate *d; +}; + +} // namespace KNetwork + +#endif diff --git a/tdecore/tdehardwaredevices.cpp b/tdecore/tdehardwaredevices.cpp index bd5ee6ec6..d012c64aa 100644 --- a/tdecore/tdehardwaredevices.cpp +++ b/tdecore/tdehardwaredevices.cpp @@ -4458,7 +4458,7 @@ TDEGenericDevice* TDEHardwareDevices::classifyUnknownDevice(udev_device* dev, TD } // FIXME - // Much of the code in libkrandr should be integrated into/interfaced with this library + // Much of the code in libtderandr should be integrated into/interfaced with this library } if (device->type() == TDEGenericDeviceType::RootSystem) { @@ -5587,7 +5587,7 @@ TQPixmap TDEHardwareDevices::getDeviceTypeIconFromType(TDEGenericDeviceType::TDE ret = DesktopIcon("kcmpci", size); } else if (query == TDEGenericDeviceType::Backlight) { - ret = DesktopIcon("kscreensaver", size); // FIXME + ret = DesktopIcon("tdescreensaver", size); // FIXME } else if (query == TDEGenericDeviceType::Battery) { ret = DesktopIcon("energy", size); diff --git a/tdecore/tdemultipledrag.cpp b/tdecore/tdemultipledrag.cpp new file mode 100644 index 000000000..db71c9e87 --- /dev/null +++ b/tdecore/tdemultipledrag.cpp @@ -0,0 +1,82 @@ +/* This file is part of the KDE project + Copyright (C) 2001 David Faure + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "tdemultipledrag.h" +#include "kdebug.h" + +#ifndef QT_NO_DRAGANDDROP + +KMultipleDrag::KMultipleDrag( TQWidget *dragSource, const char *name ) + : TQDragObject( dragSource, name ) +{ + m_dragObjects.setAutoDelete( true ); +} + +void KMultipleDrag::addDragObject( TQDragObject *dragObject ) +{ + //kdDebug() << "KMultipleDrag::addDragObject" << endl; + m_dragObjects.append( dragObject ); + // We need to find out how many formats this dragObject supports + int i = 0; + while ( dragObject->format( i ) ) + ++i; + m_numberFormats.append( i ); // e.g. if it supports two formats, 0 and 1, store 2. +} + +TQByteArray KMultipleDrag::encodedData( const char *mime ) const +{ + //kdDebug() << "KMultipleDrag::encodedData " << mime << endl; + // Iterate over the drag objects, and find the format in the right one + TQPtrListIterator it( m_dragObjects ); + for ( ; it.current(); ++it ) + { + for ( int i = 0; it.current()->format( i ); ++i ) + { + if ( ::qstrcmp( it.current()->format( i ), mime ) == 0 ) + return it.current()->encodedData( mime ); + } + } + return TQByteArray(); +} + +const char* KMultipleDrag::format( int i ) const +{ + //kdDebug() << "KMultipleDrag::format " << i << endl; + // example: m_numberFormats: 1, 4 + // m_dragObjects: storeddrag, textdrag + // i=0 -> storeddrag->format( 0 ) + // i=1 -> textdrag->format( 0 ) + // i=2 -> textdrag->format( 1 ) + // etc. + TQValueList::ConstIterator nit = m_numberFormats.begin(); + TQValueList::ConstIterator nend = m_numberFormats.end(); + TQPtrListIterator it( m_dragObjects ); + for ( ; nit != nend && i >= *nit ; ++nit, ++it ) + i -= *nit; + if ( it.current() ) + return it.current()->format( i ); + return 0; +} + +void KMultipleDrag::virtual_hook( int, void* ) +{ /*BASE::virtual_hook( id, data );*/ } + +#include "tdemultipledrag.moc" + +#endif diff --git a/tdecore/tdemultipledrag.h b/tdecore/tdemultipledrag.h new file mode 100644 index 000000000..42baf3530 --- /dev/null +++ b/tdecore/tdemultipledrag.h @@ -0,0 +1,105 @@ +/* This file is part of the KDE project + Copyright (C) 2001 David Faure + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KMULTIPLEDRAG_H +#define KMULTIPLEDRAG_H + +#ifndef QT_NO_DRAGANDDROP + +#include +#include +#include "tdelibs_export.h" + +class KMultipleDragPrivate; +/** + * This class makes it easy for applications to provide a drag object + * (for drag-n-drop or for clipboard) that has several representations + * of the same data, under different formats. + * + * Instead of creating a specific class for each case (as would otherwise + * be necessary), you can simply create independent drag objects (e.g. + * a TQImageDrag object and a KURLDrag object), and bundle them together + * using KMultipleDrag. + * + * Sample code for this: + * + * \code + * KMultipleDrag *drag = new KMultipleDrag( parentWidget ); + * drag->addDragObject( new TQImageDrag( someQImage, 0 ) ); + * drag->addDragObject( new KURLDrag( someKURL, 0 ) ); + * drag->drag(); + * \endcode + * + * Note that the drag objects added to the multiple drag become owned by it. + * For that reason their parent should be 0. + * + * @author David Faure + */ +class TDECORE_EXPORT KMultipleDrag : public TQDragObject +{ + Q_OBJECT + +public: + /** + * Create a new KMultipleDrag object. + * @param dragSource the parent object which is the source of the data, + * 0 for a parent-less object + * @param name the name of the object, can be 0 + */ + KMultipleDrag( TQWidget *dragSource = 0, const char *name = 0 ); + + /** + * Call this to add each underlying drag object to the multiple drag object. + * The drag object should not have a parent because the multiple drag object + * will own it. + * + * @param dragObject the drag object to add. Should have no parent object. + */ + void addDragObject( TQDragObject *dragObject ); + + /** + * Returns the data of a drag object with that supports the given + * mime type. + * @param mime the mime type to search + * @return the data, or a null byte array if not found + * @reimp + */ + virtual TQByteArray encodedData( const char *mime ) const; + + /** + * Returns the @p i'th supported format, or 0. + * @param i the number of the format to check + * @return the format with the number @p i, or 0 otherwise + * @reimp + */ + virtual const char* format( int i ) const; + +protected: +// KDE4: make private + TQPtrList m_dragObjects; + TQValueList m_numberFormats; +protected: + virtual void virtual_hook( int id, void* data ); +private: + KMultipleDragPrivate* d; +}; + +#endif // QT_NO_DRAGANDDROP + +#endif // KMULTIPLEDRAG_H diff --git a/tdecore/tdesycoca.cpp b/tdecore/tdesycoca.cpp new file mode 100644 index 000000000..f433510d6 --- /dev/null +++ b/tdecore/tdesycoca.cpp @@ -0,0 +1,528 @@ +/* This file is part of the KDE libraries + * Copyright (C) 1999-2000 Waldo Bastian + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation; + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + **/ + +#include "config.h" + +#include "tdesycoca.h" +#include "tdesycocatype.h" +#include "tdesycocafactory.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#ifdef HAVE_SYS_MMAN_H +#include +#endif + +#ifdef Q_OS_SOLARIS +extern "C" +{ + extern int madvise(caddr_t, size_t, int); +} +#endif + +#ifndef MAP_FAILED +#define MAP_FAILED ((void *) -1) +#endif + +template class TQPtrList; + +// The following limitations are in place: +// Maximum length of a single string: 8192 bytes +// Maximum length of a string list: 1024 strings +// Maximum number of entries: 8192 +// +// The purpose of these limitations is to limit the impact +// of database corruption. + +class KSycocaPrivate { +public: + KSycocaPrivate() { + database = 0; + readError = false; + updateSig = 0; + autoRebuild = true; + } + TQFile *database; + TQStringList changeList; + TQString language; + bool readError; + bool autoRebuild; + TQ_UINT32 updateSig; + TQStringList allResourceDirs; +}; + +int KSycoca::version() +{ + return KSYCOCA_VERSION; +} + +// Read-only constructor +KSycoca::KSycoca() + : DCOPObject("tdesycoca"), m_lstFactories(0), m_str(0), m_barray(0), bNoDatabase(false), + m_sycoca_size(0), m_sycoca_mmap(0), m_timeStamp(0) +{ + d = new KSycocaPrivate; + // Register app as able to receive DCOP messages + if (kapp && !kapp->dcopClient()->isAttached()) + { + kapp->dcopClient()->attach(); + } + // We register with DCOP _before_ we try to open the database. + // This way we can be relative sure that the KDE framework is + // up and running (tdeinit, dcopserver, klaucnher, kded) and + // that the database is up to date. + openDatabase(); + _self = this; +} + +bool KSycoca::openDatabase( bool openDummyIfNotFound ) +{ + bool result = true; + + m_sycoca_mmap = 0; + m_str = 0; + m_barray = 0; + TQString path; + TQCString tdesycoca_env = getenv("TDESYCOCA"); + if (tdesycoca_env.isEmpty()) + path = TDEGlobal::dirs()->saveLocation("cache") + "tdesycoca"; + else + path = TQFile::decodeName(tdesycoca_env); + + kdDebug(7011) << "Trying to open tdesycoca from " << path << endl; + TQFile *database = new TQFile(path); + bool bOpen = database->open( IO_ReadOnly ); + if (!bOpen) + { + path = locate("services", "tdesycoca"); + if (!path.isEmpty()) + { + kdDebug(7011) << "Trying to open global tdesycoca from " << path << endl; + delete database; + database = new TQFile(path); + bOpen = database->open( IO_ReadOnly ); + } + } + + if (bOpen) + { + fcntl(database->handle(), F_SETFD, FD_CLOEXEC); + m_sycoca_size = database->size(); +#ifdef HAVE_MMAP + m_sycoca_mmap = (const char *) mmap(0, m_sycoca_size, + PROT_READ, MAP_SHARED, + database->handle(), 0); + /* POSIX mandates only MAP_FAILED, but we are paranoid so check for + null pointer too. */ + if (m_sycoca_mmap == (const char*) MAP_FAILED || m_sycoca_mmap == 0) + { + kdDebug(7011) << "mmap failed. (length = " << m_sycoca_size << ")" << endl; +#endif + m_str = new TQDataStream(database); +#ifdef HAVE_MMAP + } + else + { +#ifdef HAVE_MADVISE + (void) madvise((char*)m_sycoca_mmap, m_sycoca_size, MADV_WILLNEED); +#endif + m_barray = new TQByteArray(); + m_barray->setRawData(m_sycoca_mmap, m_sycoca_size); + TQBuffer *buffer = new TQBuffer( *m_barray ); + buffer->open(IO_ReadWrite); + m_str = new TQDataStream( buffer); + } +#endif + bNoDatabase = false; + } + else + { + kdDebug(7011) << "Could not open tdesycoca" << endl; + + // No database file + delete database; + database = 0; + + bNoDatabase = true; + if (openDummyIfNotFound) + { + // We open a dummy database instead. + //kdDebug(7011) << "No database, opening a dummy one." << endl; + TQBuffer *buffer = new TQBuffer(); + buffer->setBuffer(TQByteArray()); + buffer->open(IO_ReadWrite); + m_str = new TQDataStream( buffer); + (*m_str) << (TQ_INT32) KSYCOCA_VERSION; + (*m_str) << (TQ_INT32) 0; + } + else + { + result = false; + } + } + m_lstFactories = new KSycocaFactoryList(); + m_lstFactories->setAutoDelete( true ); + d->database = database; + return result; +} + +// Read-write constructor - only for KBuildSycoca +KSycoca::KSycoca( bool /* dummy */ ) + : DCOPObject("tdesycoca_building"), m_lstFactories(0), m_str(0), m_barray(0), bNoDatabase(false), + m_sycoca_size(0), m_sycoca_mmap(0) +{ + d = new KSycocaPrivate; + m_lstFactories = new KSycocaFactoryList(); + m_lstFactories->setAutoDelete( true ); + _self = this; +} + +static void delete_tdesycoca_self() { + delete KSycoca::_self; +} + +KSycoca * KSycoca::self() +{ + if (!_self) { + tqAddPostRoutine(delete_tdesycoca_self); + _self = new KSycoca(); + } + return _self; +} + +KSycoca::~KSycoca() +{ + closeDatabase(); + delete d; + _self = 0L; +} + +void KSycoca::closeDatabase() +{ + QIODevice *device = 0; + if (m_str) + device = m_str->device(); +#ifdef HAVE_MMAP + if (device && m_sycoca_mmap) + { + TQBuffer *buf = static_cast(device); + buf->buffer().resetRawData(m_sycoca_mmap, m_sycoca_size); + // Solaris has munmap(char*, size_t) and everything else should + // be happy with a char* for munmap(void*, size_t) + munmap((char*) m_sycoca_mmap, m_sycoca_size); + m_sycoca_mmap = 0; + } +#endif + + delete m_str; + m_str = 0; + delete device; + if (TQT_TQIODEVICE(d->database) != device) + delete d->database; + if (m_barray) delete m_barray; + m_barray = 0; + device = 0; + d->database = 0; + // It is very important to delete all factories here + // since they cache information about the database file + delete m_lstFactories; + m_lstFactories = 0L; +} + +void KSycoca::addFactory( KSycocaFactory *factory ) +{ + assert(m_lstFactories); + m_lstFactories->append(factory); +} + +bool KSycoca::isChanged(const char *type) +{ + return self()->d->changeList.contains(type); +} + +void KSycoca::notifyDatabaseChanged(const TQStringList &changeList) +{ + d->changeList = changeList; + //kdDebug(7011) << "got a notifyDatabaseChanged signal !" << endl; + // kded tells us the database file changed + // Close the database and forget all about what we knew + // The next call to any public method will recreate + // everything that's needed. + closeDatabase(); + + // Now notify applications + emit databaseChanged(); +} + +TQDataStream * KSycoca::findEntry(int offset, KSycocaType &type) +{ + if ( !m_str ) + openDatabase(); + //kdDebug(7011) << TQString("KSycoca::_findEntry(offset=%1)").arg(offset,8,16) << endl; + m_str->device()->at(offset); + TQ_INT32 aType; + (*m_str) >> aType; + type = (KSycocaType) aType; + //kdDebug(7011) << TQString("KSycoca::found type %1").arg(aType) << endl; + return m_str; +} + +bool KSycoca::checkVersion(bool abortOnError) +{ + if ( !m_str ) + { + if( !openDatabase(false /* don't open dummy db if not found */) ) + return false; // No database found + + // We should never get here... if a database was found then m_str shouldn't be 0L. + assert(m_str); + } + m_str->device()->at(0); + TQ_INT32 aVersion; + (*m_str) >> aVersion; + if ( aVersion < KSYCOCA_VERSION ) + { + kdWarning(7011) << "Found version " << aVersion << ", expecting version " << KSYCOCA_VERSION << " or higher." << endl; + if (!abortOnError) return false; + kdError(7011) << "Outdated database ! Stop kded and restart it !" << endl; + abort(); + } + return true; +} + +TQDataStream * KSycoca::findFactory(KSycocaFactoryId id) +{ + // The constructor found no database, but we want one + if (bNoDatabase) + { + closeDatabase(); // close the dummy one + // Check if new database already available + if ( !openDatabase(false /* no dummy one*/) ) + { + static bool triedLaunchingKdeinit = false; + if (!triedLaunchingKdeinit) // try only once + { + triedLaunchingKdeinit = true; + kdDebug(7011) << "findFactory: we have no database.... launching tdeinit" << endl; + TDEApplication::startKdeinit(); + // Ok, the new database should be here now, open it. + } + if (!openDatabase(false)) + return 0L; // Still no database - uh oh + } + } + // rewind and check + if (!checkVersion(false)) + { + kdWarning(7011) << "Outdated database found" << endl; + return 0L; + } + TQ_INT32 aId; + TQ_INT32 aOffset; + while(true) + { + (*m_str) >> aId; + //kdDebug(7011) << TQString("KSycoca::findFactory : found factory %1").arg(aId) << endl; + if (aId == 0) + { + kdError(7011) << "Error, KSycocaFactory (id = " << int(id) << ") not found!" << endl; + break; + } + (*m_str) >> aOffset; + if (aId == id) + { + //kdDebug(7011) << TQString("KSycoca::findFactory(%1) offset %2").arg((int)id).arg(aOffset) << endl; + m_str->device()->at(aOffset); + return m_str; + } + } + return 0; +} + +TQString KSycoca::kfsstnd_prefixes() +{ + if (bNoDatabase) return ""; + if (!checkVersion(false)) return ""; + TQ_INT32 aId; + TQ_INT32 aOffset; + // skip factories offsets + while(true) + { + (*m_str) >> aId; + if ( aId ) + (*m_str) >> aOffset; + else + break; // just read 0 + } + // We now point to the header + TQString prefixes; + KSycocaEntry::read(*m_str, prefixes); + (*m_str) >> m_timeStamp; + KSycocaEntry::read(*m_str, d->language); + (*m_str) >> d->updateSig; + KSycocaEntry::read(*m_str, d->allResourceDirs); + return prefixes; +} + +TQ_UINT32 KSycoca::timeStamp() +{ + if (!m_timeStamp) + (void) kfsstnd_prefixes(); + return m_timeStamp; +} + +TQ_UINT32 KSycoca::updateSignature() +{ + if (!m_timeStamp) + (void) kfsstnd_prefixes(); + return d->updateSig; +} + +TQString KSycoca::language() +{ + if (d->language.isEmpty()) + (void) kfsstnd_prefixes(); + return d->language; +} + +TQStringList KSycoca::allResourceDirs() +{ + if (!m_timeStamp) + (void) kfsstnd_prefixes(); + return d->allResourceDirs; +} + +TQString KSycoca::determineRelativePath( const TQString & _fullpath, const char *_resource ) +{ + TQString sRelativeFilePath; + TQStringList dirs = TDEGlobal::dirs()->resourceDirs( _resource ); + TQStringList::ConstIterator dirsit = dirs.begin(); + for ( ; dirsit != dirs.end() && sRelativeFilePath.isEmpty(); ++dirsit ) { + // might need canonicalPath() ... + if ( _fullpath.find( *dirsit ) == 0 ) // path is dirs + relativePath + sRelativeFilePath = _fullpath.mid( (*dirsit).length() ); // skip appsdirs + } + if ( sRelativeFilePath.isEmpty() ) + kdFatal(7011) << TQString(TQString("Couldn't find %1 in any %2 dir !!!").arg( _fullpath ).arg( _resource)) << endl; + //else + // debug code + //kdDebug(7011) << sRelativeFilePath << endl; + return sRelativeFilePath; +} + +KSycoca * KSycoca::_self = 0L; + +void KSycoca::flagError() +{ + tqWarning("ERROR: KSycoca database corruption!"); + if (_self) + { + if (_self->d->readError) + return; + _self->d->readError = true; + if (_self->d->autoRebuild) + if(system("kbuildsycoca") < 0) // Rebuild the damned thing. + tqWarning("ERROR: Running KSycoca failed."); + } +} + +void KSycoca::disableAutoRebuild() +{ + d->autoRebuild = false; +} + +bool KSycoca::readError() +{ + bool b = false; + if (_self) + { + b = _self->d->readError; + _self->d->readError = false; + } + return b; +} + +void KSycocaEntry::read( TQDataStream &s, TQString &str ) +{ + TQ_UINT32 bytes; + s >> bytes; // read size of string + if ( bytes > 8192 ) { // null string or too big + if (bytes != 0xffffffff) + KSycoca::flagError(); + str = TQString::null; + } + else if ( bytes > 0 ) { // not empty + int bt = bytes/2; + str.setLength( bt ); + TQChar* ch = (TQChar *) str.unicode(); + char t[8192]; + char *b = t; + s.readRawBytes( b, bytes ); + while ( bt-- ) { + *ch++ = (ushort) (((ushort)b[0])<<8) | (uchar)b[1]; + b += 2; + } + } else { + str = ""; + } +} + +void KSycocaEntry::read( TQDataStream &s, TQStringList &list ) +{ + list.clear(); + TQ_UINT32 count; + s >> count; // read size of list + if (count >= 1024) + { + KSycoca::flagError(); + return; + } + for(TQ_UINT32 i = 0; i < count; i++) + { + TQString str; + read(s, str); + list.append( str ); + if (s.atEnd()) + { + KSycoca::flagError(); + return; + } + } +} + +void KSycoca::virtual_hook( int id, void* data ) +{ DCOPObject::virtual_hook( id, data ); } + +void KSycocaEntry::virtual_hook( int, void* ) +{ /*BASE::virtual_hook( id, data );*/ } + +#include "tdesycoca.moc" diff --git a/tdecore/tdesycoca.h b/tdecore/tdesycoca.h new file mode 100644 index 000000000..1b3355de3 --- /dev/null +++ b/tdecore/tdesycoca.h @@ -0,0 +1,187 @@ +/* This file is part of the KDE libraries + * Copyright (C) 1999 Waldo Bastian + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation; + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + **/ + +#ifndef __tdesycoca_h__ +#define __tdesycoca_h__ + +#include +#include +#include +#include "tdesycocatype.h" +#include + +class TQDataStream; +class KSycocaPrivate; +class KSycocaFactory; +class KSycocaFactoryList; + +/* + * Sycoca file version number. + * If the existing file is outdated, it will not get read + * but instead we'll ask kded to regenerate a new one... +*/ +#define KSYCOCA_VERSION 94 + +/** + * @internal + * Read-only SYstem COnfiguration CAche + */ +class TDECORE_EXPORT KSycoca : public TQObject, public DCOPObject +{ + Q_OBJECT + K_DCOP + +protected: + /** + * @internal + * Building database + */ + KSycoca( bool /* buildDatabase */ ); + +public: + + /** + * Read-only database + */ + KSycoca(); + + /** + * Get or create the only instance of KSycoca (read-only) + */ + static KSycoca *self(); + + virtual ~KSycoca(); + + static int version(); + + /** + * @internal - called by factories in read-only mode + * This is how factories get a stream to an entry + */ + TQDataStream *findEntry(int offset, KSycocaType &type); + /** + * @internal - called by factories in read-only mode + */ + TQDataStream *findFactory( KSycocaFactoryId id); + /** + * @internal - returns kfsstnd stored inside database + */ + TQString kfsstnd_prefixes(); + /** + * @internal - returns language stored inside database + */ + TQString language(); + + /** + * @internal - returns timestamp of database + * + * The database contains all changes made _before_ this time and + * _might_ contain changes made after that. + */ + TQ_UINT32 timeStamp(); + + /** + * @internal - returns update signature of database + * + * Signature that keeps track of changes to + * $TDEDIR/share/services/update_tdesycoca + * + * Touching this file causes the database to be recreated + * from scratch. + */ + TQ_UINT32 updateSignature(); + + /** + * @internal - returns all directories with information + * stored inside sycoca. + */ + TQStringList allResourceDirs(); + + /** + * @internal - add a factory + */ + void addFactory( KSycocaFactory * ); + + /** + * @internal + * @return true if building (i.e. if a KBuildSycoca); + */ + virtual bool isBuilding() { return false; } + + /** + * @internal - disables launching of kbuildsycoca + */ + void disableAutoRebuild(); + + /** + * Determine relative path for a .desktop file from a full path and a resource name + */ + static TQString determineRelativePath( const TQString & _fullpath, const char *_resource ); + + /** + * When you receive a "databaseChanged" signal, you can query here if + * a change has occurred in a specific resource type. + * @see KStandardDirs for the various resource types. + */ + static bool isChanged(const char *type); + + /** + * A read error occurs. + */ + static void flagError(); + + /** + * Returns read error status and clears flag. + */ + static bool readError(); + +k_dcop: + /** + * internal function for receiving kded/kbuildsycoca's signal, when the sycoca file changes + */ + void notifyDatabaseChanged(const TQStringList &); + +signals: + /** + * Connect to this to get notified when the database changes + * (Usually apps showing icons do a 'refresh' to take into account the new mimetypes) + */ + void databaseChanged(); + +protected: + bool checkVersion(bool abortOnError=true); + bool openDatabase(bool openDummyIfNotFound=true); + void closeDatabase(); + KSycocaFactoryList *m_lstFactories; + TQDataStream *m_str; + TQByteArray *m_barray; + bool bNoDatabase; + size_t m_sycoca_size; + const char *m_sycoca_mmap; + TQ_UINT32 m_timeStamp; + +public: + static KSycoca *_self; // Internal use only. + +protected: + virtual void virtual_hook( int id, void* data ); +private: + KSycocaPrivate *d; +}; + +#endif diff --git a/tdecore/tdesycocadict.cpp b/tdecore/tdesycocadict.cpp new file mode 100644 index 000000000..702c163a7 --- /dev/null +++ b/tdecore/tdesycocadict.cpp @@ -0,0 +1,454 @@ +/* This file is part of the KDE libraries + * Copyright (C) 1999 Waldo Bastian + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation; + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + **/ + +#include "tdesycocadict.h" +#include "tdesycocaentry.h" +#include "tdesycoca.h" + +#include +#include +#include +#include + +namespace +{ +struct string_entry { + string_entry(TQString _key, KSycocaEntry *_payload) + { keyStr = _key; key = keyStr.unicode(); length = keyStr.length(); payload = _payload; hash = 0; } + uint hash; + int length; + const TQChar *key; + TQString keyStr; + KSycocaEntry *payload; +}; +} + +template class TQPtrList; + +class KSycocaDictStringList : public TQPtrList +{ +public: + KSycocaDictStringList(); +}; + +KSycocaDictStringList::KSycocaDictStringList() +{ + setAutoDelete(true); +} + +KSycocaDict::KSycocaDict() + : d(0), mStr(0), mOffset(0) +{ +} + +KSycocaDict::KSycocaDict(TQDataStream *str, int offset) + : d(0), mStr(str), mOffset(offset) +{ + TQ_UINT32 test1, test2; + str->device()->at(offset); + (*str) >> test1 >> test2; + if ((test1 > 0x000fffff) || (test2 > 1024)) + { + KSycoca::flagError(); + mHashTableSize = 0; + mOffset = 0; + return; + } + + str->device()->at(offset); + (*str) >> mHashTableSize; + (*str) >> mHashList; + mOffset = str->device()->at(); // Start of hashtable +} + +KSycocaDict::~KSycocaDict() +{ + delete d; +} + +void +KSycocaDict::add(const TQString &key, KSycocaEntry *payload) +{ + if (key.isEmpty()) return; // Not allowed (should never happen) + if (!payload) return; // Not allowed! + if (!d) + { + d = new KSycocaDictStringList(); + } + + string_entry *entry= new string_entry(key, payload); + d->append(entry); +} + +void +KSycocaDict::remove(const TQString &key) +{ + if (d) + { + for(string_entry *entry=d->first(); entry; entry = d->next()) + { + if (entry->keyStr == key) + { + d->remove(); + break; + } + } + } +} + +int +KSycocaDict::find_string(const TQString &key ) +{ + //kdDebug(7011) << TQString("KSycocaDict::find_string(%1)").arg(key) << endl; + + if (!mStr || !mOffset) + { + kdError(7011) << "No database available!" << endl; + return 0; + } + + if (mHashTableSize == 0) + return 0; // Unlikely to find anything :-] + + // Read hash-table data + uint hash = hashKey(key) % mHashTableSize; + //kdDebug(7011) << TQString("hash is %1").arg(hash) << endl; + + uint off = mOffset+sizeof(TQ_INT32)*hash; + //kdDebug(7011) << TQString("off is %1").arg(off,8,16) << endl; + mStr->device()->at( off ); + + TQ_INT32 offset; + (*mStr) >> offset; + + //kdDebug(7011) << TQString("offset is %1").arg(offset,8,16) << endl; + if (offset == 0) + return 0; + + if (offset > 0) + return offset; // Positive ID + + // Lookup duplicate list. + offset = -offset; + + mStr->device()->at(offset); + //kdDebug(7011) << TQString("Looking up duplicate list at %1").arg(offset,8,16) << endl; + + while(true) + { + (*mStr) >> offset; + if (offset == 0) break; + TQString dupkey; + (*mStr) >> dupkey; + //kdDebug(7011) << TQString(">> %1 %2").arg(offset,8,16).arg(dupkey) << endl; + if (dupkey == key) return offset; + } + //kdWarning(7011) << "Not found!" << endl; + + return 0; +} + +uint +KSycocaDict::count() +{ + if (!d) return 0; + + return d->count(); +} + +void +KSycocaDict::clear() +{ + delete d; + d = 0; +} + +uint +KSycocaDict::hashKey( const TQString &key) +{ + int l = key.length(); + register uint h = 0; + + for(uint i = 0; i < mHashList.count(); i++) + { + int pos = mHashList[i]; + if (pos < 0) + { + pos = -pos-1; + if (pos < l) + h = ((h * 13) + (key[l-pos].cell() % 29)) & 0x3ffffff; + } + else + { + pos = pos-1; + if (pos < l) + h = ((h * 13) + (key[pos].cell() % 29)) & 0x3ffffff; + } + } + return h; +} + +// +// Calculate the diversity of the strings at position 'pos' +static int +calcDiversity(KSycocaDictStringList *d, int pos, int sz) +{ + if (pos == 0) return 0; + bool *matrix = (bool *) calloc(sz, sizeof(bool)); + uint usz = sz; + + if (pos < 0) + { + pos = -pos-1; + for(string_entry *entry=d->first(); entry; entry = d->next()) + { + register int l = entry->length; + if (pos < l && pos != 0) + { + register uint hash = ((entry->hash * 13) + (entry->key[l-pos].cell() % 29)) & 0x3ffffff; + matrix[ hash % usz ] = true; + } + } + } + else + { + pos = pos-1; + for(string_entry *entry=d->first(); entry; entry = d->next()) + { + if (pos < entry->length) + { + register uint hash = ((entry->hash * 13) + (entry->key[pos].cell() % 29)) & 0x3ffffff; + matrix[ hash % usz ] = true; + } + } + } + int diversity = 0; + for(int i=0;i< sz;i++) + if (matrix[i]) diversity++; + + free((void *) matrix); + + return diversity; +} + +// +// Add the diversity of the strings at position 'pos' +static void +addDiversity(KSycocaDictStringList *d, int pos) +{ + if (pos == 0) return; + if (pos < 0) + { + pos = -pos-1; + for(string_entry *entry=d->first(); entry; entry = d->next()) + { + register int l = entry->length; + if (pos < l) + entry->hash = ((entry->hash * 13) + (entry->key[l-pos].cell() % 29)) & 0x3fffffff; + } + } + else + { + pos = pos - 1; + for(string_entry *entry=d->first(); entry; entry = d->next()) + { + if (pos < entry->length) + entry->hash = ((entry->hash * 13) + (entry->key[pos].cell() % 29)) & 0x3fffffff; + } + } +} + + +void +KSycocaDict::save(TQDataStream &str) +{ + if (count() == 0) + { + mHashTableSize = 0; + mHashList.clear(); + str << mHashTableSize; + str << mHashList; + return; + } + + mOffset = str.device()->at(); + + //kdDebug(7011) << TQString("KSycocaDict: %1 entries.").arg(count()) << endl; + + //kdDebug(7011) << "Calculating hash keys.." << endl; + + int maxLength = 0; + //kdDebug(7011) << "Finding maximum string length" << endl; + for(string_entry *entry=d->first(); entry; entry = d->next()) + { + entry->hash = 0; + if (entry->length > maxLength) + maxLength = entry->length; + } + + //kdDebug(7011) << TQString("Max string length = %1").arg(maxLength) << endl; + + // use "almost prime" number for sz (to calculate diversity) and later + // for the table size of big tables + // int sz = d->count()*5-1; + register unsigned int sz = count()*4 + 1; + while(!(((sz % 3) && (sz % 5) && (sz % 7) && (sz % 11) && (sz % 13)))) sz+=2; + + int maxDiv = 0; + int maxPos = 0; + int lastDiv = 0; + + mHashList.clear(); + + // try to limit diversity scan by "predicting" positions + // with high diversity + int *oldvec=new int[maxLength*2+1]; + for (int i=0; i<(maxLength*2+1); i++) oldvec[i]=0; + int mindiv=0; + + while(true) + { + int divsum=0,divnum=0; + + maxDiv = 0; + maxPos = 0; + for(int pos=-maxLength; pos <= maxLength; pos++) + { + // cut off + if (oldvec[pos+maxLength] maxDiv) + { + maxDiv = diversity; + maxPos = pos; + } + oldvec[pos+maxLength]=diversity; + divsum+=diversity; divnum++; + } + // arbitrary cut-off value 3/4 of average seems to work + if (divnum) + mindiv=(3*divsum)/(4*divnum); + + if (maxDiv <= lastDiv) + break; + // tqWarning("Max Div = %d at pos %d", maxDiv, maxPos); + lastDiv = maxDiv; + addDiversity(d, maxPos); + mHashList.append(maxPos); + } + + delete [] oldvec; + + for(string_entry *entry=d->first(); entry; entry = d->next()) + { + entry->hash = hashKey(entry->keyStr); + } +// fprintf(stderr, "Calculating minimum table size..\n"); + + mHashTableSize = sz; + + struct hashtable_entry { + string_entry *entry; + TQPtrList *duplicates; + int duplicate_offset; + }; + + hashtable_entry *hashTable = new hashtable_entry[ sz ]; + + //kdDebug(7011) << "Clearing hashtable..." << endl; + for (unsigned int i=0; i < sz; i++) + { + hashTable[i].entry = 0; + hashTable[i].duplicates = 0; + } + + //kdDebug(7011) << "Filling hashtable..." << endl; + for(string_entry *entry=d->first(); entry; entry = d->next()) + { + int hash = entry->hash % sz; + if (!hashTable[hash].entry) + { // First entry + hashTable[hash].entry = entry; + } + else + { + if (!hashTable[hash].duplicates) + { // Second entry, build duplicate list. + hashTable[hash].duplicates = new TQPtrList(); + hashTable[hash].duplicates->append(hashTable[hash].entry); + hashTable[hash].duplicate_offset = 0; + } + hashTable[hash].duplicates->append(entry); + } + } + + str << mHashTableSize; + str << mHashList; + + mOffset = str.device()->at(); // mOffset points to start of hashTable + //kdDebug(7011) << TQString("Start of Hash Table, offset = %1").arg(mOffset,8,16) << endl; + + for(int pass = 1; pass <= 2; pass++) + { + str.device()->at(mOffset); + //kdDebug(7011) << TQString("Writing hash table (pass #%1)").arg(pass) << endl; + for(uint i=0; i < mHashTableSize; i++) + { + TQ_INT32 tmpid; + if (!hashTable[i].entry) + tmpid = (TQ_INT32) 0; + else if (!hashTable[i].duplicates) + tmpid = (TQ_INT32) hashTable[i].entry->payload->offset(); // Positive ID + else + tmpid = (TQ_INT32) -hashTable[i].duplicate_offset; // Negative ID + str << tmpid; + //kdDebug(7011) << TQString("Hash table : %1").arg(tmpid,8,16) << endl; + } + //kdDebug(7011) << TQString("End of Hash Table, offset = %1").arg(str.device()->at(),8,16) << endl; + + //kdDebug(7011) << TQString("Writing duplicate lists (pass #%1)").arg(pass) << endl; + for(uint i=0; i < mHashTableSize; i++) + { + if (hashTable[i].duplicates) + { + TQPtrList *dups = hashTable[i].duplicates; + hashTable[i].duplicate_offset = str.device()->at(); + + /*kdDebug(7011) << TQString("Duplicate lists: Offset = %1 list_size = %2") .arg(hashTable[i].duplicate_offset,8,16).arg(dups->count()) << endl; +*/ + for(string_entry *dup = dups->first(); dup; dup=dups->next()) + { + str << (TQ_INT32) dup->payload->offset(); // Positive ID + str << dup->keyStr; // Key (TQString) + } + str << (TQ_INT32) 0; // End of list marker (0) + } + } + //kdDebug(7011) << TQString("End of Dict, offset = %1").arg(str.device()->at(),8,16) << endl; + } + + //kdDebug(7011) << "Cleaning up hash table." << endl; + for(uint i=0; i < mHashTableSize; i++) + { + delete hashTable[i].duplicates; + } + delete [] hashTable; +} + diff --git a/tdecore/tdesycocadict.h b/tdecore/tdesycocadict.h new file mode 100644 index 000000000..006e72a61 --- /dev/null +++ b/tdecore/tdesycocadict.h @@ -0,0 +1,123 @@ +/* This file is part of the KDE libraries + * Copyright (C) 1999 Waldo Bastian + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation; + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + **/ + +#ifndef __tdesycocadict_h__ +#define __tdesycocadict_h__ + +#include +#include +#include +#include "tdelibs_export.h" + +class KSycocaEntry; +class KSycocaDictStringList; + +/** + * @internal + * Hash table implementation for the sycoca database file + */ +class TDECORE_EXPORT KSycocaDict +{ +public: + /** + * Create an empty dict, for building the database + */ + KSycocaDict(); + /** + * Create a dict from an existing database + */ + KSycocaDict(TQDataStream *str, int offset); + + ~KSycocaDict(); + + /** + * Adds a 'payload' to the dictionary with key 'key'. + * + * 'payload' should have a valid offset by the time + * the dictionary gets saved. + **/ + void add(const TQString &key, KSycocaEntry *payload); + + /** + * Removes the 'payload' from the dictionary with key 'key'. + * + * Not very fast, use with care O(N) + **/ + void remove(const TQString &key); + + /** + * Looks up an entry identified by 'key'. + * + * If 0 is returned, no matching entry exists. + * Otherwise, the offset of the entry is returned. + * + * NOTE: It is not guaranteed that this entry is + * indeed the one you were looking for. + * After loading the entry you should check that it + * indeed matches the search key. If it doesn't + * then no matching entry exists. + */ + int find_string(const TQString &key ); + + /** + * The number of entries in the dictionary. + * + * Only valid when building the database. + */ + uint count(); + + /** + * Reset the dictionary. + * + * Only valid when building the database. + */ + void clear(); + + /** + * Save the dictionary to the stream + * A reasonable fast hash algorithm will be created. + * + * Typically this will find 90% of the entries directly. + * Average hash table size: nrOfItems * 20 bytes. + * Average duplicate list size: nrOfItms * avgKeyLength / 5. + * + * Unknown keys have an average 20% chance to give a false hit. + * (That's why your program should check the result) + * + * Example: + * Assume 1000 items with an average key length of 60 bytes. + * + * Approx. 900 items will hash directly to the right entry. + * Approx. 100 items require a lookup in the duplicate list. + * + * The hash table size will be approx. 20Kb. + * The duplicate list size will be approx. 12Kb. + **/ + void save(TQDataStream &str); + +protected: + TQ_UINT32 hashKey( const TQString &); +private: + KSycocaDictStringList *d; + TQDataStream *mStr; + TQ_INT32 mOffset; + TQ_UINT32 mHashTableSize; + TQValueList mHashList; +}; + +#endif diff --git a/tdecore/tdesycocaentry.h b/tdecore/tdesycocaentry.h new file mode 100644 index 000000000..a4e2512e0 --- /dev/null +++ b/tdecore/tdesycocaentry.h @@ -0,0 +1,123 @@ +/* This file is part of the KDE libraries + * Copyright (C) 1999 Waldo Bastian + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation; + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + **/ + +#ifndef __tdesycocaentry_h__ +#define __tdesycocaentry_h__ + +#include "tdesycocatype.h" + +#include +#include +class TQDataStream; + +/** + * Base class for all Sycoca entries. + * + * You can't create an instance of KSycocaEntry, but it provides + * the common functionality for servicetypes and services. + * + * @internal + * @see http://developer.kde.org/documentation/library/kdeqt/trinityarch/tdesycoca.html + */ +class TDECORE_EXPORT KSycocaEntry : public KShared +{ + +public: + virtual bool isType(KSycocaType t) const { return (t == KST_KSycocaEntry); } + virtual KSycocaType sycocaType() const { return KST_KSycocaEntry; } + +public: + typedef KSharedPtr Ptr; + typedef TQValueList List; +public: // KDoc seems to barf on those typedefs and generates no docs after them + /** + * Default constructor + */ + KSycocaEntry(const TQString &path) : mOffset(0), m_bDeleted(false), mPath(path) { } + + /** + * Safe demarshalling functions. + */ + static void read( TQDataStream &s, TQString &str ); + static void read( TQDataStream &s, TQStringList &list ); + + /** + * @internal + * Restores itself from a stream. + */ + KSycocaEntry( TQDataStream &_str, int offset ) : + mOffset( offset ), m_bDeleted(false) + { + read(_str, mPath); + } + + /** + * @return the name of this entry + */ + virtual TQString name() const = 0; + + /** + * @return the path of this entry + * The path can be absolute or relative. + * The corresponding factory should know relative to what. + */ + TQString entryPath() const { return mPath; } + + /** + * @return true if valid + */ + virtual bool isValid() const = 0; + + /** + * @return true if deleted + */ + virtual bool isDeleted() const { return m_bDeleted; } + + /** + * @internal + * @return the position of the entry in the sycoca file + */ + int offset() { return mOffset; } + + /** + * @internal + * Save ourselves to the database. Don't forget to call the parent class + * first if you override this function. + */ + virtual void save(TQDataStream &s) + { + mOffset = s.device()->at(); // store position in member variable + s << (TQ_INT32) sycocaType() << mPath; + } + + /** + * @internal + * Load ourselves from the database. Don't call the parent class! + */ + virtual void load(TQDataStream &) = 0; + +private: + int mOffset; +protected: + bool m_bDeleted; + TQString mPath; +protected: + virtual void virtual_hook( int id, void* data ); +}; + +#endif diff --git a/tdecore/tdesycocafactory.cpp b/tdecore/tdesycocafactory.cpp new file mode 100644 index 000000000..d7d350ddf --- /dev/null +++ b/tdecore/tdesycocafactory.cpp @@ -0,0 +1,202 @@ +/* This file is part of the KDE libraries + * Copyright (C) 1999 David Faure + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation; + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + **/ + +#include "tdesycoca.h" +#include "tdesycocatype.h" +#include "tdesycocafactory.h" +#include "tdesycocaentry.h" +#include "tdesycocadict.h" +#include +#include +#include + +template class TQDict; +template class TQDict >; + +KSycocaFactory::KSycocaFactory(KSycocaFactoryId factory_id) + : m_resourceList(0), m_entryDict(0), m_sycocaDict(0) +{ + if (!KSycoca::self()->isBuilding()) // read-only database ? + { + m_str = KSycoca::self()->findFactory( factory_id ); + // can't call factoryId() here since the constructor can't call inherited methods + if (m_str) // Can be 0 in case of errors + { + // Read position of index tables.... + TQ_INT32 i; + (*m_str) >> i; + m_sycocaDictOffset = i; + (*m_str) >> i; + m_beginEntryOffset = i; + (*m_str) >> i; + m_endEntryOffset = i; + + int saveOffset = m_str->device()->at(); + // Init index tables + m_sycocaDict = new KSycocaDict(m_str, m_sycocaDictOffset); + saveOffset = m_str->device()->at(saveOffset); + } + } + else + { + // Build new database! + m_str = 0; + m_resourceList = 0; + m_entryDict = new KSycocaEntryDict(977); + m_entryDict->setAutoDelete(true); + m_sycocaDict = new KSycocaDict(); + m_beginEntryOffset = 0; + m_endEntryOffset = 0; + + // m_resourceList will be filled in by inherited constructors + } + KSycoca::self()->addFactory(this); +} + +KSycocaFactory::~KSycocaFactory() +{ + delete m_entryDict; + delete m_sycocaDict; +} + +void +KSycocaFactory::saveHeader(TQDataStream &str) +{ + // Write header + str.device()->at(mOffset); + str << (TQ_INT32) m_sycocaDictOffset; + str << (TQ_INT32) m_beginEntryOffset; + str << (TQ_INT32) m_endEntryOffset; +} + +void +KSycocaFactory::save(TQDataStream &str) +{ + if (!m_entryDict) return; // Error! Function should only be called when + // building database + if (!m_sycocaDict) return; // Error! + + mOffset = str.device()->at(); // store position in member variable + m_sycocaDictOffset = 0; + + // Write header (pass #1) + saveHeader(str); + + m_beginEntryOffset = str.device()->at(); + + // Write all entries. + int entryCount = 0; + for(TQDictIterator it ( *m_entryDict ); + it.current(); + ++it) + { + KSycocaEntry *entry = (*it.current()); + entry->save(str); + entryCount++; + } + + m_endEntryOffset = str.device()->at(); + + // Write indices... + // Linear index + str << (TQ_INT32) entryCount; + for(TQDictIterator it ( *m_entryDict ); + it.current(); + ++it) + { + KSycocaEntry *entry = (*it.current()); + str << (TQ_INT32) entry->offset(); + } + + // Dictionary index + m_sycocaDictOffset = str.device()->at(); + m_sycocaDict->save(str); + + int endOfFactoryData = str.device()->at(); + + // Update header (pass #2) + saveHeader(str); + + // Seek to end. + str.device()->at(endOfFactoryData); +} + +void +KSycocaFactory::addEntry(KSycocaEntry *newEntry, const char *) +{ + if (!m_entryDict) return; // Error! Function should only be called when + // building database + + if (!m_sycocaDict) return; // Error! + + TQString name = newEntry->name(); + m_entryDict->insert( name, new KSycocaEntry::Ptr(newEntry) ); + m_sycocaDict->add( name, newEntry ); +} + +void +KSycocaFactory::removeEntry(KSycocaEntry *newEntry) +{ + if (!m_entryDict) return; // Error! Function should only be called when + // building database + + if (!m_sycocaDict) return; // Error! + + TQString name = newEntry->name(); + m_entryDict->remove( name ); + m_sycocaDict->remove( name ); +} + +KSycocaEntry::List KSycocaFactory::allEntries() +{ + KSycocaEntry::List list; + if (!m_str) return list; + + // Assume we're NOT building a database + + m_str->device()->at(m_endEntryOffset); + TQ_INT32 entryCount; + (*m_str) >> entryCount; + + if (entryCount > 8192) + { + KSycoca::flagError(); + return list; + } + + TQ_INT32 *offsetList = new TQ_INT32[entryCount]; + for(int i = 0; i < entryCount; i++) + { + (*m_str) >> offsetList[i]; + } + + for(int i = 0; i < entryCount; i++) + { + KSycocaEntry *newEntry = createEntry(offsetList[i]); + if (newEntry) + { + list.append( KSycocaEntry::Ptr( newEntry ) ); + } + } + delete [] offsetList; + return list; +} + +void KSycocaFactory::virtual_hook( int /*id*/, void* /*data*/) +{ /*BASE::virtual_hook( id, data );*/ } + diff --git a/tdecore/tdesycocafactory.h b/tdecore/tdesycocafactory.h new file mode 100644 index 000000000..4569fff5a --- /dev/null +++ b/tdecore/tdesycocafactory.h @@ -0,0 +1,143 @@ +/* This file is part of the KDE libraries + * Copyright (C) 1999 Waldo Bastian + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation; + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + **/ + +#ifndef __tdesycocafactory_h__ +#define __tdesycocafactory_h__ + +#include "tdesycocatype.h" +#include "tdesycocaentry.h" + +#include +#include +class KSycoca; +class TQStringList; +class TQString; +class KSycocaDict; +class KSycocaResourceList; + +typedef TQDict KSycocaEntryDict; + +/** + * @internal + * Base class for sycoca factories + */ +class TDECORE_EXPORT KSycocaFactory +{ +public: + virtual KSycocaFactoryId factoryId() const = 0; + +protected: // virtual class + /** + * Create a factory which can be used to lookup from/create a database + * (depending on KSycoca::isBuilding()) + */ + KSycocaFactory( KSycocaFactoryId factory_id ); + +public: + virtual ~KSycocaFactory(); + + /** + * @return the position of the factory in the sycoca file + */ + int offset() { return mOffset; } + + /** + * @return the dict, for special use by KBuildSycoca + */ + KSycocaEntryDict * entryDict() { return m_entryDict; } + + /** + * Construct an entry from a config file. + * To be implemented in the real factories. + */ + virtual KSycocaEntry *createEntry(const TQString &file, const char *resource) = 0; + + /** + * Add an entry + */ + virtual void addEntry(KSycocaEntry *newEntry, const char *resource); + + /** + * Remove an entry + * Not very fast, use with care. O(N) + */ + void removeEntry(KSycocaEntry *newEntry); + + /** + * Read an entry from the database + */ + virtual KSycocaEntry *createEntry(int offset)=0; + + /** + * Get a list of all entries from the database. + */ + KSycocaEntry::List allEntries(); + + /** + * Saves all entries it maintains as well as index files + * for these entries to the stream 'str'. + * + * Also sets mOffset to the starting position. + * + * The stream is positioned at the end of the last index. + * + * Don't forget to call the parent first when you override + * this function. + */ + virtual void save(TQDataStream &str); + + /** + * Writes out a header to the stream 'str'. + * The baseclass positions the stream correctly. + * + * Don't forget to call the parent first when you override + * this function. + */ + virtual void saveHeader(TQDataStream &str); + + /** + * @return the resources for which this factory is responsible. + */ + virtual const KSycocaResourceList * resourceList() const { return m_resourceList; } + +private: + int mOffset; + +protected: + int m_sycocaDictOffset; + int m_beginEntryOffset; + int m_endEntryOffset; + TQDataStream *m_str; + + KSycocaResourceList *m_resourceList; + KSycocaEntryDict *m_entryDict; + KSycocaDict *m_sycocaDict; +protected: + virtual void virtual_hook( int id, void* data ); +}; + +/** This, instead of a typedef, allows to declare "class ..." in header files + * @internal + */ +class TDECORE_EXPORT KSycocaFactoryList : public TQPtrList +{ +public: + KSycocaFactoryList() { } +}; + +#endif diff --git a/tdecore/tdesycocatype.h b/tdecore/tdesycocatype.h new file mode 100644 index 000000000..8407782fc --- /dev/null +++ b/tdecore/tdesycocatype.h @@ -0,0 +1,64 @@ +/* This file is part of the KDE project + Copyright (C) 1998, 1999 Torben Weis + Waldo Bastian + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef __tdesycocatype_h__ +#define __tdesycocatype_h__ + +/** + * \relates KSycocaEntry + * A KSycocaType is a code (out of the KSycocaType enum) assigned to each + * class type derived from KSycocaEntry . + * To use it, call the macro K_SYCOCATYPE( your_typecode, parent_class ) + * at the top of your class definition. + */ +enum KSycocaType { KST_KSycocaEntry = 0, KST_KService = 1, KST_KServiceType = 2, KST_KMimeType = 3, + KST_KFolderType = 4, KST_KDEDesktopMimeType = 5, KST_KExecMimeType = 6, + KST_KServiceGroup = 7, KST_KImageIOFormat = 8, KST_KProtocolInfo = 9, + KST_KServiceSeparator = 10, + KST_KCustom = 1000 }; + +#define K_SYCOCATYPE( type, baseclass ) \ +public: \ + virtual bool isType(KSycocaType t) const { if (t == type) return true; return baseclass::isType(t);} \ + virtual KSycocaType sycocaType() const { return type; } \ +private: + +/** + * \relates KSycocaFactory + * A KSycocaFactoryId is a code (out of the KSycocaFactoryId enum) + * assigned to each class type derived from KSycocaFactory. + * To use it, call the macro K_SYCOCAFACTORY( your_factory_id ) + * at the top of your class definition. + */ +enum KSycocaFactoryId { KST_KServiceFactory = 1, + KST_KServiceTypeFactory = 2, + KST_KServiceGroupFactory = 3, + KST_KImageIO = 4, + KST_KProtocolInfoFactory = 5, + KST_CTimeInfo = 100 }; + +#define K_SYCOCAFACTORY( factory_id ) \ +public: \ + virtual KSycocaFactoryId factoryId() const { return factory_id; } \ +private: + + + +#endif diff --git a/tdecore/tests/Makefile.am b/tdecore/tests/Makefile.am index e35ae68a4..9d2c5259c 100644 --- a/tdecore/tests/Makefile.am +++ b/tdecore/tests/Makefile.am @@ -79,8 +79,8 @@ kstdacceltest_SOURCES = kstdacceltest.cpp kglobaltest_SOURCES = kglobaltest.cpp ktimezonestest_SOURCES = ktimezonestest.cpp -check_LTLIBRARIES = kunittest_kconfig.la +check_LTLIBRARIES = tdeunittest_kconfig.la -kunittest_kconfig_la_SOURCES = kconfigtest.cpp -kunittest_kconfig_la_LIBADD = $(LIB_KUNITTEST) -kunittest_kconfig_la_LDFLAGS = -module $(KDE_CHECK_PLUGIN) +tdeunittest_kconfig_la_SOURCES = kconfigtest.cpp +tdeunittest_kconfig_la_LIBADD = $(LIB_KUNITTEST) +tdeunittest_kconfig_la_LDFLAGS = -module $(KDE_CHECK_PLUGIN) diff --git a/tdecore/tests/dcopkonqtest.cpp b/tdecore/tests/dcopkonqtest.cpp index 543efd706..79137cd5f 100644 --- a/tdecore/tests/dcopkonqtest.cpp +++ b/tdecore/tests/dcopkonqtest.cpp @@ -27,8 +27,8 @@ debug("sending configure to object KonquerorIface in konqueror"); debug("ko"); /// BROADCAST -debug("sending databaseChanged to object ksycoca in all apps"); - if (kapp->dcopClient()->send( "*", "ksycoca", "databaseChanged()", data )) +debug("sending databaseChanged to object tdesycoca in all apps"); + if (kapp->dcopClient()->send( "*", "tdesycoca", "databaseChanged()", data )) debug("ok"); else debug("ko"); diff --git a/tdecore/tests/kapptest.cpp b/tdecore/tests/kapptest.cpp index 53bb0f9f3..bae6a9c2e 100644 --- a/tdecore/tests/kapptest.cpp +++ b/tdecore/tests/kapptest.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include int main(int argc, char *argv[]) diff --git a/tdecore/tests/kconfigtest.cpp b/tdecore/tests/kconfigtest.cpp index e4768119c..d3421a3d8 100644 --- a/tdecore/tests/kconfigtest.cpp +++ b/tdecore/tests/kconfigtest.cpp @@ -17,8 +17,8 @@ Boston, MA 02110-1301, USA. */ -#include -#include +#include +#include #include @@ -31,7 +31,7 @@ private: void revertEntries(); }; -KUNITTEST_MODULE( kunittest_kconfig, "TDEConfigTest" ) +KUNITTEST_MODULE( tdeunittest_kconfig, "TDEConfigTest" ) KUNITTEST_MODULE_REGISTER_TESTER( TDEConfigTest ) // test data -- cgit v1.2.1